Skip to content

Latest commit

 

History

History
18 lines (11 loc) · 1.65 KB

File metadata and controls

18 lines (11 loc) · 1.65 KB

IsFixedStringLiteralType medium

by 蛭子屋双六 @sugoroku-y

Take the Challenge    日本語

Sometimes you may want to determine whether a string literal is a definite type. For example, when you want to check whether the type specified as a class identifier is a fixed string literal type.

type Action<ID extends string> = { readonly id: ID };

Since it must be fixed, the following types must be determined as false.

  • never type
  • Union of string literal types
  • Template literal types with embedded string, number, bigint, boolean

Determine whether the given type S is a definite string literal type.


Back Share your Solutions Check out Solutions