Skip to content

4. Typescript

Johann Buscail edited this page Oct 17, 2021 · 3 revisions

Nowadays, it's common to use Typescript in projects.
You can type the variables by using typescript generics:

import { mjml2HTMLParser } from "@wavychat/mjml-parser";

interface IMJMLVariables {
    username: string;
    name: string;
}

mjml2HTMLParser<IMJMLVariables>({
   template: {
      vars: {
         // wil throw ts error since types aren't corresponding
         username: 123,
         name: true
      }
   }
})
Clone this wiki locally