Skip to content

Commit

Permalink
Make getTypeOfSymbol, isArrayType, isTupleType public on TypeChecker (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey authored Feb 2, 2023
1 parent 8fd1308 commit 9ee3315
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4927,7 +4927,7 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost {

export interface TypeChecker {
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
/** @internal */ getTypeOfSymbol(symbol: Symbol): Type;
getTypeOfSymbol(symbol: Symbol): Type;
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
getPropertiesOfType(type: Type): Symbol[];
getPropertyOfType(type: Type, propertyName: string): Symbol | undefined;
Expand Down Expand Up @@ -5153,9 +5153,21 @@ export interface TypeChecker {
/** @internal */ getRecursionIdentity(type: Type): object | undefined;
/** @internal */ getUnmatchedProperties(source: Type, target: Type, requireOptionalProperties: boolean, matchDiscriminantProperties: boolean): IterableIterator<Symbol>;

/** @internal */ isArrayType(type: Type): boolean;
/** @internal */ isTupleType(type: Type): boolean;
/** @internal */ isArrayLikeType(type: 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
* extends `Array` (for example, the TypeScript AST's `NodeArray` type).
*/
isArrayType(type: Type): boolean;
/**
* True if this type is a tuple type. This function will _not_ return true if
* passed a type which extends from a tuple.
*/
isTupleType(type: Type): boolean;
/**
* True if this type is assignable to `ReadonlyArray<any>`.
*/
isArrayLikeType(type: Type): boolean;

/**
* True if `contextualType` should not be considered for completions because
Expand Down
16 changes: 16 additions & 0 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6310,6 +6310,7 @@ declare namespace ts {
}
interface TypeChecker {
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
getTypeOfSymbol(symbol: Symbol): Type;
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
getPropertiesOfType(type: Type): Symbol[];
getPropertyOfType(type: Type, propertyName: string): Symbol | undefined;
Expand Down Expand Up @@ -6400,6 +6401,21 @@ declare namespace ts {
getApparentType(type: Type): Type;
getBaseConstraintOfType(type: Type): Type | undefined;
getDefaultFromTypeParameter(type: Type): Type | undefined;
/**
* 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
* extends `Array` (for example, the TypeScript AST's `NodeArray` type).
*/
isArrayType(type: Type): boolean;
/**
* True if this type is a tuple type. This function will _not_ return true if
* passed a type which extends from a tuple.
*/
isTupleType(type: Type): boolean;
/**
* True if this type is assignable to `ReadonlyArray<any>`.
*/
isArrayLikeType(type: Type): boolean;
getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined;
/**
* Depending on the operation performed, it may be appropriate to throw away the checker
Expand Down
16 changes: 16 additions & 0 deletions tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2335,6 +2335,7 @@ declare namespace ts {
}
interface TypeChecker {
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
getTypeOfSymbol(symbol: Symbol): Type;
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
getPropertiesOfType(type: Type): Symbol[];
getPropertyOfType(type: Type, propertyName: string): Symbol | undefined;
Expand Down Expand Up @@ -2425,6 +2426,21 @@ declare namespace ts {
getApparentType(type: Type): Type;
getBaseConstraintOfType(type: Type): Type | undefined;
getDefaultFromTypeParameter(type: Type): Type | undefined;
/**
* 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
* extends `Array` (for example, the TypeScript AST's `NodeArray` type).
*/
isArrayType(type: Type): boolean;
/**
* True if this type is a tuple type. This function will _not_ return true if
* passed a type which extends from a tuple.
*/
isTupleType(type: Type): boolean;
/**
* True if this type is assignable to `ReadonlyArray<any>`.
*/
isArrayLikeType(type: Type): boolean;
getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined;
/**
* Depending on the operation performed, it may be appropriate to throw away the checker
Expand Down

0 comments on commit 9ee3315

Please sign in to comment.