Skip to content

v1.0.8

Latest
Compare
Choose a tag to compare
@zgid123 zgid123 released this 29 Apr 17:13

Release v1.0.8

Changelogs

allow custom type for TypeScript usage

before

interface IUserProps {
  email: string;
  displayName: string;
}

const template = '{{ user.displayName }} just joined the chat.';

interpole(
  template,
  {
    user: {
      email: 'test',
      displayName: 'test',
    },
  },
  {
    exactMatch: true,
    specElement: '_',
    pattern: '{{ _ }}',
  },
);

This will raise error for typing

after

interface IUserProps {
  email: string;
  displayName: string;
}

const template = '{{ user.displayName }} just joined the chat.';

interpole<{ user: IUserProps }>(
  template,
  {
    user: {
      email: 'test',
      displayName: 'test',
    },
  },
  {
    exactMatch: true,
    specElement: '_',
    pattern: '{{ _ }}',
  },
);

or

interface IUserProps {
  email: string;
  displayName: string;
}

const template = '{{ user.displayName }} just joined the chat.';

const user: IUserProps = {
  email: 'test',
  displayName: 'test',
};

interpole(
  template,
  {
    user,
  },
  {
    exactMatch: true,
    specElement: '_',
    pattern: '{{ _ }}',
  },
);