mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Make isTypeAssignableTo public on TypeChecker (#56448)
This commit is contained in:
+14
-1
@@ -5158,7 +5158,20 @@ export interface TypeChecker {
|
||||
/** @internal */ getPromiseLikeType(): Type;
|
||||
/** @internal */ getAsyncIterableType(): Type | undefined;
|
||||
|
||||
/** @internal */ isTypeAssignableTo(source: Type, target: Type): boolean;
|
||||
/**
|
||||
* Returns true if the "source" type is assignable to the "target" type.
|
||||
*
|
||||
* ```ts
|
||||
* 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
|
||||
* ```
|
||||
*/
|
||||
isTypeAssignableTo(source: Type, target: Type): boolean;
|
||||
/** @internal */ createAnonymousType(symbol: Symbol | undefined, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], indexInfos: IndexInfo[]): Type;
|
||||
/** @internal */ createSignature(
|
||||
declaration: SignatureDeclaration | undefined,
|
||||
|
||||
+14
@@ -6832,6 +6832,20 @@ declare namespace ts {
|
||||
* is `never`. Instead, use `type.flags & TypeFlags.Never`.
|
||||
*/
|
||||
getNeverType(): Type;
|
||||
/**
|
||||
* Returns true if the "source" type is assignable to the "target" type.
|
||||
*
|
||||
* ```ts
|
||||
* 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
|
||||
* ```
|
||||
*/
|
||||
isTypeAssignableTo(source: Type, target: Type): boolean;
|
||||
/**
|
||||
* True if this type is the `Array` or `ReadonlyArray` type from lib.d.ts.
|
||||
* This function will _not_ return true if passed a type which
|
||||
|
||||
Reference in New Issue
Block a user