Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make getTypeOfSymbol, isArrayType, isTupleType public on TypeChecker #52467

Merged
merged 3 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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