Test whether a type is a literal type.
Type to test
Distinguishes string, number, and boolean literals from their corresponding primitive base types. The any type always resolves to false to avoid false positives.
any
false
type A = IsLiteral< 'hello' >; // truetype B = IsLiteral< 42 >; // truetype C = IsLiteral< true >; // truetype D = IsLiteral< string >; // false Copy
type A = IsLiteral< 'hello' >; // truetype B = IsLiteral< 42 >; // truetype C = IsLiteral< true >; // truetype D = IsLiteral< string >; // false
Test whether a type is a literal type.