mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Move utilities for getting type parameter constraints and defaults from public lazy members to services (#20162)
This commit is contained in:
@@ -251,6 +251,7 @@ namespace ts {
|
||||
getSuggestionForNonexistentProperty: (node, type) => getSuggestionForNonexistentProperty(node, type),
|
||||
getSuggestionForNonexistentSymbol: (location, name, meaning) => getSuggestionForNonexistentSymbol(location, escapeLeadingUnderscores(name), meaning),
|
||||
getBaseConstraintOfType,
|
||||
getDefaultFromTypeParameter: type => type && type.flags & TypeFlags.TypeParameter ? getDefaultFromTypeParameter(type as TypeParameter) : undefined,
|
||||
resolveName(name, location, meaning) {
|
||||
return resolveName(location, escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
|
||||
},
|
||||
|
||||
@@ -2771,7 +2771,8 @@ namespace ts {
|
||||
getApparentType(type: Type): Type;
|
||||
getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined;
|
||||
getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined;
|
||||
/* @internal */ getBaseConstraintOfType(type: Type): Type | undefined;
|
||||
getBaseConstraintOfType(type: Type): Type | undefined;
|
||||
getDefaultFromTypeParameter(type: Type): Type | undefined;
|
||||
|
||||
/* @internal */ getAnyType(): Type;
|
||||
/* @internal */ getStringType(): Type;
|
||||
@@ -3575,15 +3576,17 @@ namespace ts {
|
||||
|
||||
export interface TypeVariable extends Type {
|
||||
/* @internal */
|
||||
resolvedBaseConstraint: Type;
|
||||
resolvedBaseConstraint?: Type;
|
||||
/* @internal */
|
||||
resolvedIndexType: IndexType;
|
||||
resolvedIndexType?: IndexType;
|
||||
}
|
||||
|
||||
// Type parameters (TypeFlags.TypeParameter)
|
||||
export interface TypeParameter extends TypeVariable {
|
||||
/** Retrieve using getConstraintFromTypeParameter */
|
||||
constraint: Type; // Constraint
|
||||
/* @internal */
|
||||
constraint?: Type; // Constraint
|
||||
/* @internal */
|
||||
default?: Type;
|
||||
/* @internal */
|
||||
target?: TypeParameter; // Instantiation target
|
||||
|
||||
@@ -472,6 +472,12 @@ namespace ts {
|
||||
getNonNullableType(): Type {
|
||||
return this.checker.getNonNullableType(this);
|
||||
}
|
||||
getConstraint(): Type | undefined {
|
||||
return this.checker.getBaseConstraintOfType(this);
|
||||
}
|
||||
getDefault(): Type | undefined {
|
||||
return this.checker.getDefaultFromTypeParameter(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SignatureObject implements Signature {
|
||||
|
||||
@@ -50,6 +50,8 @@ namespace ts {
|
||||
getNumberIndexType(): Type | undefined;
|
||||
getBaseTypes(): BaseType[] | undefined;
|
||||
getNonNullableType(): Type;
|
||||
getConstraint(): Type | undefined;
|
||||
getDefault(): Type | undefined;
|
||||
}
|
||||
|
||||
export interface Signature {
|
||||
|
||||
+4
-3
@@ -1783,6 +1783,8 @@ declare namespace ts {
|
||||
getApparentType(type: Type): Type;
|
||||
getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined;
|
||||
getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined;
|
||||
getBaseConstraintOfType(type: Type): Type | undefined;
|
||||
getDefaultFromTypeParameter(type: Type): Type | undefined;
|
||||
}
|
||||
enum NodeBuilderFlags {
|
||||
None = 0,
|
||||
@@ -2119,9 +2121,6 @@ declare namespace ts {
|
||||
interface TypeVariable extends Type {
|
||||
}
|
||||
interface TypeParameter extends TypeVariable {
|
||||
/** Retrieve using getConstraintFromTypeParameter */
|
||||
constraint: Type;
|
||||
default?: Type;
|
||||
}
|
||||
interface IndexedAccessType extends TypeVariable {
|
||||
objectType: Type;
|
||||
@@ -3843,6 +3842,8 @@ declare namespace ts {
|
||||
getNumberIndexType(): Type | undefined;
|
||||
getBaseTypes(): BaseType[] | undefined;
|
||||
getNonNullableType(): Type;
|
||||
getConstraint(): Type | undefined;
|
||||
getDefault(): Type | undefined;
|
||||
}
|
||||
interface Signature {
|
||||
getDeclaration(): SignatureDeclaration;
|
||||
|
||||
+4
-3
@@ -1783,6 +1783,8 @@ declare namespace ts {
|
||||
getApparentType(type: Type): Type;
|
||||
getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined;
|
||||
getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined;
|
||||
getBaseConstraintOfType(type: Type): Type | undefined;
|
||||
getDefaultFromTypeParameter(type: Type): Type | undefined;
|
||||
}
|
||||
enum NodeBuilderFlags {
|
||||
None = 0,
|
||||
@@ -2119,9 +2121,6 @@ declare namespace ts {
|
||||
interface TypeVariable extends Type {
|
||||
}
|
||||
interface TypeParameter extends TypeVariable {
|
||||
/** Retrieve using getConstraintFromTypeParameter */
|
||||
constraint: Type;
|
||||
default?: Type;
|
||||
}
|
||||
interface IndexedAccessType extends TypeVariable {
|
||||
objectType: Type;
|
||||
@@ -3843,6 +3842,8 @@ declare namespace ts {
|
||||
getNumberIndexType(): Type | undefined;
|
||||
getBaseTypes(): BaseType[] | undefined;
|
||||
getNonNullableType(): Type;
|
||||
getConstraint(): Type | undefined;
|
||||
getDefault(): Type | undefined;
|
||||
}
|
||||
interface Signature {
|
||||
getDeclaration(): SignatureDeclaration;
|
||||
|
||||
Reference in New Issue
Block a user