ts-template-string
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

Template Strings

Conveniently typed string templates with a syntax heavily inpired by Template Literals:

const template = new TemplateString('Hello ${placeholder}');
template.fill({ placeholder: 'world! 🌍' }) // 'Hello world 🌍'

The template are typed using Template Literal Types and provide a nice developer experience:

const anotherTemplate = new TemplateString('A ${mandatory} ${placeholder}!');

anotherTemplate.fill({ placeholder: 'world! 🌍' }) // ❌
anotherTemplate.fill({ mandatory: 'typed', redundant: 'word' }) // ❌
anotherTemplate.fill({ andatory: 'typed' }) // ❌
anotherTemplate.fill({ mandatory: 'typed' }) // ✅

Readme

Keywords

none

Package Sidebar

Install

npm i ts-template-string

Weekly Downloads

1

Version

0.1.0

License

ISC

Unpacked Size

27.5 kB

Total Files

40

Last publish

Collaborators

  • lucaschultz