Skip to content

Commit

Permalink
Merge pull request #5949 from Microsoft/typeParametersAsConstraints
Browse files Browse the repository at this point in the history
Type parameters as constraints
  • Loading branch information
ahejlsberg committed Dec 11, 2015
2 parents 58400ed + 5cb2b6a commit ff78477
Show file tree
Hide file tree
Showing 178 changed files with 12,662 additions and 3,206 deletions.
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 @@ -867,7 +867,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 @@ -2066,7 +2066,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 @@ -2312,6 +2311,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

0 comments on commit ff78477

Please sign in to comment.