How to require a specific string in TypeScript interface

This was released in version 1.8 as “string literal types”

What’s New in Typescript – String Literal Types

Example from the page:

interface AnimationOptions {
  deltaX: number;
  deltaY: number;
  easing: "ease-in" | "ease-out" | "ease-in-out";
}

Leave a Comment