Simple, type-safe string interpolation
// Import the tpl function and some default stringifiersimporttpl,{NUMBER,STRING}from'type-template';// Define a custom stringifier, a fancy name for a function mapping a value to a stringconstDATE=(value: Date)=>value.toLocaleString();// Create a templateconstmyTemplate=tpl`Something ${{num:NUMBER}} something ${{myDate:DATE}} something ${{str:STRING}}`;// myTemplate is now a function you can use for interpolationconstmyString=myTemplate({// These arguments are all type-checkednum: 96,myDate: newDate(),str: 'some other thing',});// -> 'Something 96 something 10/8/2018, 11:56:52 AM something some other thing'