diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 09ac5125b4ca3..49b148e18d570 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1703,7 +1703,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { createIndexInfo, getAnyType: () => anyType, getStringType: () => stringType, + getStringLiteralType, getNumberType: () => numberType, + getNumberLiteralType, + getBigIntType: () => bigintType, createPromiseType, createArrayType, getElementTypeOfArrayType, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 87a72ea860f3b..abd82400fa1c4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5099,17 +5099,46 @@ export interface TypeChecker { getBaseConstraintOfType(type: Type): Type | undefined; getDefaultFromTypeParameter(type: Type): Type | undefined; - /** @internal */ getAnyType(): Type; - /** @internal */ getStringType(): Type; - /** @internal */ getNumberType(): Type; - /** @internal */ getBooleanType(): Type; - /** @internal */ getFalseType(fresh?: boolean): Type; - /** @internal */ getTrueType(fresh?: boolean): Type; - /** @internal */ getVoidType(): Type; - /** @internal */ getUndefinedType(): Type; - /** @internal */ getNullType(): Type; - /** @internal */ getESSymbolType(): Type; - /** @internal */ getNeverType(): Type; + /** + * Gets the intrinsic `any` type. There are multiple types that act as `any` used internally in the compiler, + * so the type returned by this function should not be used in equality checks to determine if another type + * is `any`. Instead, use `type.flags & TypeFlags.Any`. + */ + getAnyType(): Type; + getStringType(): Type; + getStringLiteralType(value: string): StringLiteralType; + getNumberType(): Type; + getNumberLiteralType(value: number): NumberLiteralType; + getBigIntType(): Type; + getBooleanType(): Type; + /* eslint-disable @typescript-eslint/unified-signatures */ + /** @internal */ + getFalseType(fresh?: boolean): Type; + getFalseType(): Type; + /** @internal */ + getTrueType(fresh?: boolean): Type; + getTrueType(): Type; + /* eslint-enable @typescript-eslint/unified-signatures */ + getVoidType(): Type; + /** + * Gets the intrinsic `undefined` type. There are multiple types that act as `undefined` used internally in the compiler + * depending on compiler options, so the type returned by this function should not be used in equality checks to determine + * if another type is `undefined`. Instead, use `type.flags & TypeFlags.Undefined`. + */ + getUndefinedType(): Type; + /** + * Gets the intrinsic `null` type. There are multiple types that act as `null` used internally in the compiler, + * so the type returned by this function should not be used in equality checks to determine if another type + * is `null`. Instead, use `type.flags & TypeFlags.Null`. + */ + getNullType(): Type; + getESSymbolType(): Type; + /** + * Gets the intrinsic `never` type. There are multiple types that act as `never` used internally in the compiler, + * so the type returned by this function should not be used in equality checks to determine if another type + * is `never`. Instead, use `type.flags & TypeFlags.Never`. + */ + getNeverType(): Type; /** @internal */ getOptionalType(): Type; /** @internal */ getUnionType(types: Type[], subtypeReduction?: UnionReduction): Type; /** @internal */ createArrayType(elementType: Type): Type; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 035abc4d7ff10..3a322ee3083a4 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -6401,6 +6401,40 @@ declare namespace ts { getApparentType(type: Type): Type; getBaseConstraintOfType(type: Type): Type | undefined; getDefaultFromTypeParameter(type: Type): Type | undefined; + /** + * Gets the intrinsic `any` type. There are multiple types that act as `any` used internally in the compiler, + * so the type returned by this function should not be used in equality checks to determine if another type + * is `any`. Instead, use `type.flags & TypeFlags.Any`. + */ + getAnyType(): Type; + getStringType(): Type; + getStringLiteralType(value: string): StringLiteralType; + getNumberType(): Type; + getNumberLiteralType(value: number): NumberLiteralType; + getBigIntType(): Type; + getBooleanType(): Type; + getFalseType(): Type; + getTrueType(): Type; + getVoidType(): Type; + /** + * Gets the intrinsic `undefined` type. There are multiple types that act as `undefined` used internally in the compiler + * depending on compiler options, so the type returned by this function should not be used in equality checks to determine + * if another type is `undefined`. Instead, use `type.flags & TypeFlags.Undefined`. + */ + getUndefinedType(): Type; + /** + * Gets the intrinsic `null` type. There are multiple types that act as `null` used internally in the compiler, + * so the type returned by this function should not be used in equality checks to determine if another type + * is `null`. Instead, use `type.flags & TypeFlags.Null`. + */ + getNullType(): Type; + getESSymbolType(): Type; + /** + * Gets the intrinsic `never` type. There are multiple types that act as `never` used internally in the compiler, + * so the type returned by this function should not be used in equality checks to determine if another type + * is `never`. Instead, use `type.flags & TypeFlags.Never`. + */ + getNeverType(): Type; /** * 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 diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index a8a5c3bb97f1b..46eed4e91b867 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2426,6 +2426,40 @@ declare namespace ts { getApparentType(type: Type): Type; getBaseConstraintOfType(type: Type): Type | undefined; getDefaultFromTypeParameter(type: Type): Type | undefined; + /** + * Gets the intrinsic `any` type. There are multiple types that act as `any` used internally in the compiler, + * so the type returned by this function should not be used in equality checks to determine if another type + * is `any`. Instead, use `type.flags & TypeFlags.Any`. + */ + getAnyType(): Type; + getStringType(): Type; + getStringLiteralType(value: string): StringLiteralType; + getNumberType(): Type; + getNumberLiteralType(value: number): NumberLiteralType; + getBigIntType(): Type; + getBooleanType(): Type; + getFalseType(): Type; + getTrueType(): Type; + getVoidType(): Type; + /** + * Gets the intrinsic `undefined` type. There are multiple types that act as `undefined` used internally in the compiler + * depending on compiler options, so the type returned by this function should not be used in equality checks to determine + * if another type is `undefined`. Instead, use `type.flags & TypeFlags.Undefined`. + */ + getUndefinedType(): Type; + /** + * Gets the intrinsic `null` type. There are multiple types that act as `null` used internally in the compiler, + * so the type returned by this function should not be used in equality checks to determine if another type + * is `null`. Instead, use `type.flags & TypeFlags.Null`. + */ + getNullType(): Type; + getESSymbolType(): Type; + /** + * Gets the intrinsic `never` type. There are multiple types that act as `never` used internally in the compiler, + * so the type returned by this function should not be used in equality checks to determine if another type + * is `never`. Instead, use `type.flags & TypeFlags.Never`. + */ + getNeverType(): Type; /** * 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