isTypeAssignableTo
Returns true if the "source" type is assignable to the "target" type.
declare const abcLiteral: ts.Type; // Type of "abc"
declare const stringType: ts.Type; // Type of string
isTypeAssignableTo(abcLiteral, abcLiteral); // true; "abc" is assignable to "abc"
isTypeAssignableTo(abcLiteral, stringType); // true; "abc" is assignable to string
isTypeAssignableTo(stringType, abcLiteral); // false; string is not assignable to "abc"
isTypeAssignableTo(stringType, stringType); // true; string is assignable to string
Content copied to clipboard