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

Type parameters as constraints #5949

Merged
merged 12 commits into from
Dec 11, 2015
210 changes: 97 additions & 113 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/compiler/declarationEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,9 @@ namespace ts {
}

function emitSignatureDeclaration(node: SignatureDeclaration) {
const prevEnclosingDeclaration = enclosingDeclaration;
enclosingDeclaration = node;

// Construct signature or constructor type write new Signature
if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) {
write("new ");
Expand All @@ -1321,9 +1324,6 @@ namespace ts {
write("(");
}

const prevEnclosingDeclaration = enclosingDeclaration;
enclosingDeclaration = node;

// Parameters
emitCommaList(node.parameters, emitParameterDeclaration);

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@
"category": "Error",
"code": 2312
},
"Constraint of a type parameter cannot reference any type parameter from the same type parameter list.": {
"Type parameter '{0}' has a circular constraint.": {
"category": "Error",
"code": 2313
},
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,6 @@ namespace ts {
resolvedSymbol?: Symbol; // Cached name resolution result
flags?: NodeCheckFlags; // Set of flags specific to Node
enumMemberValue?: number; // Constant value of enum member
isIllegalTypeReferenceInConstraint?: boolean; // Is type reference in constraint refers to the type parameter from the same list
isVisible?: boolean; // Is this node visible
generatedName?: string; // Generated name for module, enum, or import declaration
generatedNames?: Map<string>; // Generated names table for source file
Expand Down Expand Up @@ -2286,6 +2285,7 @@ namespace ts {
inferUnionTypes: boolean; // Infer union types for disjoint candidates (otherwise undefinedType)
inferences: TypeInferences[]; // Inferences made for each type parameter
inferredTypes: Type[]; // Inferred type for each type parameter
mapper?: TypeMapper; // Type mapper for this inference context
failedTypeParameterIndex?: number; // Index of type parameter for which inference failed
// It is optional because in contextual signature instantiation, nothing fails
}
Expand Down
136 changes: 0 additions & 136 deletions tests/baselines/reference/anyAssignableToEveryType2.errors.txt

This file was deleted.

Loading