Skip to content

lucaschultz/ts-template-string

Repository files navigation

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' }) // ✅

About

String templates for Typescript (and Javascript)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published