Move utilities for getting type parameter constraints and defaults from public lazy members to services (#20162)

This commit is contained in:
Wesley Wigham
2017-11-28 13:37:42 -08:00
committed by GitHub
parent cb5fd53731
commit 5ee640d2b6
6 changed files with 24 additions and 10 deletions
+1
View File
@@ -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);
},
+7 -4
View File
@@ -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
+6
View File
@@ -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 {
+2
View File
@@ -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
View File
@@ -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
View File
@@ -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;