Skip to content

Commit ff78477

Browse files
committed
Merge pull request #5949 from Microsoft/typeParametersAsConstraints
Type parameters as constraints
2 parents 58400ed + 5cb2b6a commit ff78477

File tree

178 files changed

+12662
-3206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+12662
-3206
lines changed

src/compiler/checker.ts

Lines changed: 97 additions & 113 deletions
Large diffs are not rendered by default.

src/compiler/declarationEmitter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,9 @@ namespace ts {
13091309
}
13101310

13111311
function emitSignatureDeclaration(node: SignatureDeclaration) {
1312+
const prevEnclosingDeclaration = enclosingDeclaration;
1313+
enclosingDeclaration = node;
1314+
13121315
// Construct signature or constructor type write new Signature
13131316
if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) {
13141317
write("new ");
@@ -1321,9 +1324,6 @@ namespace ts {
13211324
write("(");
13221325
}
13231326

1324-
const prevEnclosingDeclaration = enclosingDeclaration;
1325-
enclosingDeclaration = node;
1326-
13271327
// Parameters
13281328
emitCommaList(node.parameters, emitParameterDeclaration);
13291329

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@
867867
"category": "Error",
868868
"code": 2312
869869
},
870-
"Constraint of a type parameter cannot reference any type parameter from the same type parameter list.": {
870+
"Type parameter '{0}' has a circular constraint.": {
871871
"category": "Error",
872872
"code": 2313
873873
},

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,6 @@ namespace ts {
20662066
resolvedSymbol?: Symbol; // Cached name resolution result
20672067
flags?: NodeCheckFlags; // Set of flags specific to Node
20682068
enumMemberValue?: number; // Constant value of enum member
2069-
isIllegalTypeReferenceInConstraint?: boolean; // Is type reference in constraint refers to the type parameter from the same list
20702069
isVisible?: boolean; // Is this node visible
20712070
generatedName?: string; // Generated name for module, enum, or import declaration
20722071
generatedNames?: Map<string>; // Generated names table for source file
@@ -2312,6 +2311,7 @@ namespace ts {
23122311
inferUnionTypes: boolean; // Infer union types for disjoint candidates (otherwise undefinedType)
23132312
inferences: TypeInferences[]; // Inferences made for each type parameter
23142313
inferredTypes: Type[]; // Inferred type for each type parameter
2314+
mapper?: TypeMapper; // Type mapper for this inference context
23152315
failedTypeParameterIndex?: number; // Index of type parameter for which inference failed
23162316
// It is optional because in contextual signature instantiation, nothing fails
23172317
}

tests/baselines/reference/anyAssignableToEveryType2.errors.txt

Lines changed: 0 additions & 136 deletions
This file was deleted.

0 commit comments

Comments
 (0)