From 5bb2fe03eabe31af76018d9ef68124c01d540aae Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 3 Feb 2017 16:34:42 -0800 Subject: [PATCH] Simplify checkTypeParameterListsIdentical --- src/compiler/checker.ts | 155 +++++++----------- src/compiler/types.ts | 1 + ...nstructSignaturesWithOverloads2.errors.txt | 5 +- ...acesWithDuplicateTypeParameters.errors.txt | 5 +- ...GenericInterfaceWithTheSameName.errors.txt | 11 +- .../genericDefaultsErrors.errors.txt | 8 +- ...terfaceWithMultipleDeclarations.errors.txt | 11 +- .../multipleNumericIndexers.errors.txt | 5 +- .../nonIdenticalTypeConstraints.errors.txt | 11 +- ...cesDifferingByTypeParameterName.errors.txt | 17 +- ...esDifferingByTypeParameterName2.errors.txt | 11 +- ...erfacesWithDifferentConstraints.errors.txt | 11 +- ...ithTheSameNameButDifferentArity.errors.txt | 11 +- 13 files changed, 152 insertions(+), 110 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8f847daa679..e1db046d0d0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -376,7 +376,7 @@ namespace ts { Type, ResolvedBaseConstructorType, DeclaredType, - ResolvedReturnType, + ResolvedReturnType } const builtinGlobals = createMap(); @@ -18549,115 +18549,67 @@ namespace ts { } /** Check that type parameter lists are identical across multiple declarations */ - function checkTypeParameterListsIdentical(node: ClassLikeDeclaration | InterfaceDeclaration, symbol: Symbol) { + function checkTypeParameterListsIdentical(symbol: Symbol) { if (symbol.declarations.length === 1) { return; } - // Resolve the type parameters and minimum type argument count for all declarations - resolveTypeParametersOfClassOrInterface(symbol); - - const typeParameters = getSymbolLinks(symbol).typeParameters; - const maxTypeArgumentCount = length(typeParameters); - const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - const numTypeParameters = length(node.typeParameters); - - // If this declaration has too few or too many type parameters, we report an error - if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { - error(node.name, Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); - return; - } - - for (let i = 0; i < numTypeParameters; i++) { - const source = node.typeParameters[i]; - const target = typeParameters[i]; - - // If the type parameter node does not have the same name as the resolved type - // parameter at this position, we report an error. - if (source.name.text !== target.symbol.name) { - error(node.name, Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); - return; - } - - // If the type parameter node does not have an identical constraint as the resolved - // type parameter at this position, we report an error. - const sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); - const targetConstraint = getConstraintFromTypeParameter(target); - if ((sourceConstraint || targetConstraint) && - (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { - error(node.name, Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); - return; - } - - // If the type parameter node has a default and it is not identical to the default - // for the type parameter at this position, we report an error. - const sourceDefault = source.default && getTypeFromTypeNode(source.default); - const targetDefault = getDefaultFromTypeParameter(target); - if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { - error(node.name, Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, node.name.text); - return; + const links = getSymbolLinks(symbol); + if (!links.typeParametersChecked) { + links.typeParametersChecked = true; + const type = getDeclaredTypeOfSymbol(symbol); + const declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); + if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { + // Report an error on every conflicting declaration. + const name = symbolToString(symbol); + for (const declaration of declarations) { + error(declaration.name, Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); + } } } } - function resolveTypeParametersOfClassOrInterface(symbol: Symbol) { - const links = getSymbolLinks(symbol); - if (!links.typeParameters) { - let typeParameters: TypeParameter[] | undefined; - let minTypeArgumentCount = -1; - let maxTypeArgumentCount = -1; - for (const declaration of symbol.declarations) { - if (declaration.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.InterfaceDeclaration) { - const typeParameterNodes = (declaration).typeParameters; - const numTypeParameters = length(typeParameterNodes); - if (maxTypeArgumentCount === -1) { - // For the first declaration, establish the initial maximum and - // minimum type argument counts. These only change when we - // encounter default type arguments. - maxTypeArgumentCount = numTypeParameters; - minTypeArgumentCount = numTypeParameters; - } + function areTypeParametersIdentical(declarations: (ClassDeclaration | InterfaceDeclaration)[], typeParameters: TypeParameter[]) { + const maxTypeArgumentCount = length(typeParameters); + const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (typeParameterNodes) { - if (!typeParameters) { - typeParameters = []; - } + for (const declaration of declarations) { + // If this declaration has too few or too many type parameters, we report an error + const numTypeParameters = length(declaration.typeParameters); + if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { + return false; + } - for (let i = 0; i < typeParameterNodes.length; i++) { - if (typeParameterNodes[i].default) { - // When we encounter a type parameter with a default, establish - // new minimum and maximum type arguments if necessary. - if (minTypeArgumentCount > i) { - minTypeArgumentCount = i; - } - if (maxTypeArgumentCount < i + 1) { - maxTypeArgumentCount = i + 1; - } - } - if (typeParameters.length <= i) { - // When we encounter a new type parameter at this position, - // get the declared type for the type parameter. If another - // declaration attempts to establish a type parameter with a - // different name or constraint than the first one we find, - // we will report an error when checking the type parameters. - typeParameters[i] = getDeclaredTypeOfTypeParameter(getSymbolOfNode(typeParameterNodes[i])); - } - } - } + for (let i = 0; i < numTypeParameters; i++) { + const source = declaration.typeParameters[i]; + const target = typeParameters[i]; + + // If the type parameter node does not have the same as the resolved type + // parameter at this position, we report an error. + if (source.name.text !== target.symbol.name) { + return false; + } + + // If the type parameter node does not have an identical constraint as the resolved + // type parameter at this position, we report an error. + const sourceConstraint = source.constraint && getTypeFromTypeNode(source.constraint); + const targetConstraint = getConstraintFromTypeParameter(target); + if ((sourceConstraint || targetConstraint) && + (!sourceConstraint || !targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint))) { + return false; + } + + // If the type parameter node has a default and it is not identical to the default + // for the type parameter at this position, we report an error. + const sourceDefault = source.default && getTypeFromTypeNode(source.default); + const targetDefault = getDefaultFromTypeParameter(target); + if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) { + return false; } } - if (maxTypeArgumentCount === -1) { - maxTypeArgumentCount = 0; - } - if (minTypeArgumentCount === -1) { - minTypeArgumentCount = maxTypeArgumentCount; - } - if (typeParameters && typeParameters.length > maxTypeArgumentCount) { - // Trim the type parameters to the maximum length - typeParameters.length = maxTypeArgumentCount; - } - links.typeParameters = typeParameters || emptyArray; } + + return true; } function checkClassExpression(node: ClassExpression): Type { @@ -18697,7 +18649,7 @@ namespace ts { const type = getDeclaredTypeOfSymbol(symbol); const typeWithThis = getTypeWithThisArgument(type); const staticType = getTypeOfSymbol(symbol); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. @@ -18805,6 +18757,11 @@ namespace ts { return forEach(symbol.declarations, d => isClassLike(d) ? d : undefined); } + function getClassOrInterfaceDeclarationsOfSymbol(symbol: Symbol) { + return filter(symbol.declarations, (d: Declaration): d is ClassDeclaration | InterfaceDeclaration => + d.kind === SyntaxKind.ClassDeclaration || d.kind === SyntaxKind.InterfaceDeclaration); + } + function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: BaseType): void { // TypeScript 1.0 spec (April 2014): 8.2.3 @@ -18952,7 +18909,7 @@ namespace ts { checkExportsOnMergedDeclarations(node); const symbol = getSymbolOfNode(node); - checkTypeParameterListsIdentical(node, symbol); + checkTypeParameterListsIdentical(symbol); // Only check this symbol once const firstInterfaceDecl = getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b416f26324f..8010cc7dcb0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2725,6 +2725,7 @@ isDiscriminantProperty?: boolean; // True if discriminant synthetic property resolvedExports?: SymbolTable; // Resolved exports of module exportsChecked?: boolean; // True if exports of external module have been checked + typeParametersChecked?: boolean; // True if type parameters of merged class and interface declarations have been checked. isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration bindingElement?: BindingElement; // Binding element associated with property symbol exportsSomeValue?: boolean; // True if module exports some value (not just types) diff --git a/tests/baselines/reference/constructSignaturesWithOverloads2.errors.txt b/tests/baselines/reference/constructSignaturesWithOverloads2.errors.txt index 617f7b1502f..35b130f7d6c 100644 --- a/tests/baselines/reference/constructSignaturesWithOverloads2.errors.txt +++ b/tests/baselines/reference/constructSignaturesWithOverloads2.errors.txt @@ -1,7 +1,8 @@ +tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts(27,11): error TS2428: All declarations of 'I' must have identical type parameters. tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts(32,11): error TS2428: All declarations of 'I' must have identical type parameters. -==== tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts (1 errors) ==== +==== tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSignaturesWithOverloads2.ts (2 errors) ==== // No errors expected for basic overloads of construct signatures with merged declarations // clodules @@ -29,6 +30,8 @@ tests/cases/conformance/types/objectTypeLiteral/constructSignatures/constructSig // merged interfaces interface I { + ~ +!!! error TS2428: All declarations of 'I' must have identical type parameters. new (x: number, y?: string): C; new (x: number, y: string): C; } diff --git a/tests/baselines/reference/extendedInterfacesWithDuplicateTypeParameters.errors.txt b/tests/baselines/reference/extendedInterfacesWithDuplicateTypeParameters.errors.txt index 7b47fee05af..942ead52be3 100644 --- a/tests/baselines/reference/extendedInterfacesWithDuplicateTypeParameters.errors.txt +++ b/tests/baselines/reference/extendedInterfacesWithDuplicateTypeParameters.errors.txt @@ -1,9 +1,10 @@ tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(1,42): error TS2300: Duplicate identifier 'A'. +tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(5,11): error TS2428: All declarations of 'InterfaceWithSomeTypars' must have identical type parameters. tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(9,11): error TS2428: All declarations of 'InterfaceWithSomeTypars' must have identical type parameters. tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(9,38): error TS2300: Duplicate identifier 'C'. -==== tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts (3 errors) ==== +==== tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts (4 errors) ==== interface InterfaceWithMultipleTypars { // should error ~ !!! error TS2300: Duplicate identifier 'A'. @@ -11,6 +12,8 @@ tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(9,38): err } interface InterfaceWithSomeTypars { // should not error + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2428: All declarations of 'InterfaceWithSomeTypars' must have identical type parameters. bar(): void; } diff --git a/tests/baselines/reference/genericAndNonGenericInterfaceWithTheSameName.errors.txt b/tests/baselines/reference/genericAndNonGenericInterfaceWithTheSameName.errors.txt index 8d9ebb8d276..963613b9c2d 100644 --- a/tests/baselines/reference/genericAndNonGenericInterfaceWithTheSameName.errors.txt +++ b/tests/baselines/reference/genericAndNonGenericInterfaceWithTheSameName.errors.txt @@ -1,12 +1,17 @@ +tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(3,11): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(7,11): error TS2428: All declarations of 'A' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(12,15): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(16,15): error TS2428: All declarations of 'A' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(34,22): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts(40,22): error TS2428: All declarations of 'A' must have identical type parameters. -==== tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts (3 errors) ==== +==== tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterfaceWithTheSameName.ts (6 errors) ==== // generic and non-generic interfaces with the same name do not merge interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. foo: string; } @@ -18,6 +23,8 @@ tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterf module M { interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. bar: T; } @@ -42,6 +49,8 @@ tests/cases/conformance/interfaces/declarationMerging/genericAndNonGenericInterf module M3 { export interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. foo: string; } } diff --git a/tests/baselines/reference/genericDefaultsErrors.errors.txt b/tests/baselines/reference/genericDefaultsErrors.errors.txt index 0347c547e08..46a43136b2b 100644 --- a/tests/baselines/reference/genericDefaultsErrors.errors.txt +++ b/tests/baselines/reference/genericDefaultsErrors.errors.txt @@ -6,7 +6,9 @@ tests/cases/compiler/genericDefaultsErrors.ts(7,39): error TS2344: Type 'number' tests/cases/compiler/genericDefaultsErrors.ts(11,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/genericDefaultsErrors.ts(14,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/genericDefaultsErrors.ts(18,13): error TS2345: Argument of type '"a"' is not assignable to parameter of type 'number'. +tests/cases/compiler/genericDefaultsErrors.ts(20,11): error TS2428: All declarations of 'i00' must have identical type parameters. tests/cases/compiler/genericDefaultsErrors.ts(21,11): error TS2428: All declarations of 'i00' must have identical type parameters. +tests/cases/compiler/genericDefaultsErrors.ts(23,11): error TS2428: All declarations of 'i01' must have identical type parameters. tests/cases/compiler/genericDefaultsErrors.ts(24,11): error TS2428: All declarations of 'i01' must have identical type parameters. tests/cases/compiler/genericDefaultsErrors.ts(26,27): error TS2705: Required type parameters may not follow optional type parameters. tests/cases/compiler/genericDefaultsErrors.ts(27,34): error TS2344: Type 'number' does not satisfy the constraint 'string'. @@ -21,7 +23,7 @@ tests/cases/compiler/genericDefaultsErrors.ts(39,20): error TS2304: Cannot find tests/cases/compiler/genericDefaultsErrors.ts(39,20): error TS4033: Property 'x' of exported interface has or is using private name 'T'. -==== tests/cases/compiler/genericDefaultsErrors.ts (19 errors) ==== +==== tests/cases/compiler/genericDefaultsErrors.ts (21 errors) ==== declare const x: any; @@ -57,11 +59,15 @@ tests/cases/compiler/genericDefaultsErrors.ts(39,20): error TS4033: Property 'x' !!! error TS2345: Argument of type '"a"' is not assignable to parameter of type 'number'. interface i00 { } // ok + ~~~ +!!! error TS2428: All declarations of 'i00' must have identical type parameters. interface i00 { } // error ~~~ !!! error TS2428: All declarations of 'i00' must have identical type parameters. interface i01 { } // ok + ~~~ +!!! error TS2428: All declarations of 'i01' must have identical type parameters. interface i01 { } // error ~~~ !!! error TS2428: All declarations of 'i01' must have identical type parameters. diff --git a/tests/baselines/reference/interfaceWithMultipleDeclarations.errors.txt b/tests/baselines/reference/interfaceWithMultipleDeclarations.errors.txt index 79d8b4a509a..cabc329df7e 100644 --- a/tests/baselines/reference/interfaceWithMultipleDeclarations.errors.txt +++ b/tests/baselines/reference/interfaceWithMultipleDeclarations.errors.txt @@ -1,18 +1,23 @@ +tests/cases/compiler/interfaceWithMultipleDeclarations.ts(1,11): error TS2428: All declarations of 'I1' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(3,11): error TS2428: All declarations of 'I1' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(5,11): error TS2428: All declarations of 'I1' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(7,11): error TS2428: All declarations of 'I1' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(9,11): error TS2428: All declarations of 'I1' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(11,11): error TS2428: All declarations of 'I1' must have identical type parameters. +tests/cases/compiler/interfaceWithMultipleDeclarations.ts(14,11): error TS2428: All declarations of 'I2' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(16,11): error TS2428: All declarations of 'I2' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(18,11): error TS2428: All declarations of 'I2' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(20,11): error TS2428: All declarations of 'I2' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(22,11): error TS2428: All declarations of 'I2' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(24,11): error TS2428: All declarations of 'I2' must have identical type parameters. +tests/cases/compiler/interfaceWithMultipleDeclarations.ts(27,11): error TS2428: All declarations of 'I3' must have identical type parameters. tests/cases/compiler/interfaceWithMultipleDeclarations.ts(29,11): error TS2428: All declarations of 'I3' must have identical type parameters. -==== tests/cases/compiler/interfaceWithMultipleDeclarations.ts (11 errors) ==== +==== tests/cases/compiler/interfaceWithMultipleDeclarations.ts (14 errors) ==== interface I1 { + ~~ +!!! error TS2428: All declarations of 'I1' must have identical type parameters. } interface I1 { // Name mismatch ~~ @@ -36,6 +41,8 @@ tests/cases/compiler/interfaceWithMultipleDeclarations.ts(29,11): error TS2428: } interface I2 { + ~~ +!!! error TS2428: All declarations of 'I2' must have identical type parameters. } interface I2 string> { // constraint mismatch ~~ @@ -59,6 +66,8 @@ tests/cases/compiler/interfaceWithMultipleDeclarations.ts(29,11): error TS2428: } interface I3 { + ~~ +!!! error TS2428: All declarations of 'I3' must have identical type parameters. } interface I3 { // length mismatch ~~ diff --git a/tests/baselines/reference/multipleNumericIndexers.errors.txt b/tests/baselines/reference/multipleNumericIndexers.errors.txt index 82fc444ac65..e3eaa94fa52 100644 --- a/tests/baselines/reference/multipleNumericIndexers.errors.txt +++ b/tests/baselines/reference/multipleNumericIndexers.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(5,5): error TS2375: Duplicate number index signature. +tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(8,11): error TS2428: All declarations of 'I' must have identical type parameters. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(10,5): error TS2375: Duplicate number index signature. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(15,5): error TS2375: Duplicate number index signature. tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(20,5): error TS2375: Duplicate number index signature. @@ -8,7 +9,7 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericI tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts(30,5): error TS2375: Duplicate number index signature. -==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts (8 errors) ==== +==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericIndexers.ts (9 errors) ==== // Multiple indexers of the same type are an error class C { @@ -19,6 +20,8 @@ tests/cases/conformance/types/objectTypeLiteral/indexSignatures/multipleNumericI } interface I { + ~ +!!! error TS2428: All declarations of 'I' must have identical type parameters. [x: number]: string; [x: number]: string; ~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/nonIdenticalTypeConstraints.errors.txt b/tests/baselines/reference/nonIdenticalTypeConstraints.errors.txt index 627b38579a2..6070c97cf28 100644 --- a/tests/baselines/reference/nonIdenticalTypeConstraints.errors.txt +++ b/tests/baselines/reference/nonIdenticalTypeConstraints.errors.txt @@ -1,9 +1,12 @@ +tests/cases/compiler/nonIdenticalTypeConstraints.ts(7,7): error TS2428: All declarations of 'Foo' must have identical type parameters. tests/cases/compiler/nonIdenticalTypeConstraints.ts(10,11): error TS2428: All declarations of 'Foo' must have identical type parameters. +tests/cases/compiler/nonIdenticalTypeConstraints.ts(13,11): error TS2428: All declarations of 'Qux' must have identical type parameters. tests/cases/compiler/nonIdenticalTypeConstraints.ts(16,7): error TS2428: All declarations of 'Qux' must have identical type parameters. +tests/cases/compiler/nonIdenticalTypeConstraints.ts(33,7): error TS2428: All declarations of 'Quux' must have identical type parameters. tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All declarations of 'Quux' must have identical type parameters. -==== tests/cases/compiler/nonIdenticalTypeConstraints.ts (3 errors) ==== +==== tests/cases/compiler/nonIdenticalTypeConstraints.ts (6 errors) ==== class Different { a: number; b: string; @@ -11,6 +14,8 @@ tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All de } class Foo { + ~~~ +!!! error TS2428: All declarations of 'Foo' must have identical type parameters. n: T; } interface Foo { @@ -19,6 +24,8 @@ tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All de y: T; } interface Qux { + ~~~ +!!! error TS2428: All declarations of 'Qux' must have identical type parameters. y: T; } class Qux { @@ -41,6 +48,8 @@ tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All de } class Quux { + ~~~~ +!!! error TS2428: All declarations of 'Quux' must have identical type parameters. n: T; } interface Quux { diff --git a/tests/baselines/reference/twoGenericInterfacesDifferingByTypeParameterName.errors.txt b/tests/baselines/reference/twoGenericInterfacesDifferingByTypeParameterName.errors.txt index 6c0f562ac64..09d181ed959 100644 --- a/tests/baselines/reference/twoGenericInterfacesDifferingByTypeParameterName.errors.txt +++ b/tests/baselines/reference/twoGenericInterfacesDifferingByTypeParameterName.errors.txt @@ -1,14 +1,21 @@ +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(3,11): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(7,11): error TS2428: All declarations of 'A' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(11,11): error TS2428: All declarations of 'B' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(15,11): error TS2428: All declarations of 'B' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(20,15): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(24,15): error TS2428: All declarations of 'A' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(28,15): error TS2428: All declarations of 'B' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(32,15): error TS2428: All declarations of 'B' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(50,22): error TS2428: All declarations of 'B' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts(56,22): error TS2428: All declarations of 'B' must have identical type parameters. -==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts (5 errors) ==== +==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName.ts (10 errors) ==== // type parameter names are relevant when choosing whether to merge interface declarations interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. x: T; } @@ -19,6 +26,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDiffer } interface B { + ~ +!!! error TS2428: All declarations of 'B' must have identical type parameters. x: U; } @@ -30,6 +39,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDiffer module M { interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. x: T; } @@ -40,6 +51,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDiffer } interface B { + ~ +!!! error TS2428: All declarations of 'B' must have identical type parameters. x: U; } @@ -64,6 +77,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDiffer module M3 { export interface B { + ~ +!!! error TS2428: All declarations of 'B' must have identical type parameters. x: U; } } diff --git a/tests/baselines/reference/twoGenericInterfacesDifferingByTypeParameterName2.errors.txt b/tests/baselines/reference/twoGenericInterfacesDifferingByTypeParameterName2.errors.txt index f2a0063c230..863f77cad1b 100644 --- a/tests/baselines/reference/twoGenericInterfacesDifferingByTypeParameterName2.errors.txt +++ b/tests/baselines/reference/twoGenericInterfacesDifferingByTypeParameterName2.errors.txt @@ -1,13 +1,18 @@ +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(3,11): error TS2428: All declarations of 'B' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(7,11): error TS2428: All declarations of 'B' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(8,8): error TS2304: Cannot find name 'V'. +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(12,15): error TS2428: All declarations of 'B' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(16,15): error TS2428: All declarations of 'B' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(34,22): error TS2428: All declarations of 'B' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts(40,22): error TS2428: All declarations of 'B' must have identical type parameters. -==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts (4 errors) ==== +==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDifferingByTypeParameterName2.ts (7 errors) ==== // type parameter names are relevant when choosing whether to merge interface declarations interface B { + ~ +!!! error TS2428: All declarations of 'B' must have identical type parameters. x: U; } @@ -21,6 +26,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDiffer module M { interface B { + ~ +!!! error TS2428: All declarations of 'B' must have identical type parameters. x: U; } @@ -45,6 +52,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesDiffer module M3 { export interface B { + ~ +!!! error TS2428: All declarations of 'B' must have identical type parameters. x: U; } } diff --git a/tests/baselines/reference/twoGenericInterfacesWithDifferentConstraints.errors.txt b/tests/baselines/reference/twoGenericInterfacesWithDifferentConstraints.errors.txt index 4b2455773f5..71d6f73d864 100644 --- a/tests/baselines/reference/twoGenericInterfacesWithDifferentConstraints.errors.txt +++ b/tests/baselines/reference/twoGenericInterfacesWithDifferentConstraints.errors.txt @@ -1,10 +1,15 @@ +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts(1,11): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts(5,11): error TS2428: All declarations of 'A' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts(10,15): error TS2428: All declarations of 'B' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts(14,15): error TS2428: All declarations of 'B' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts(32,22): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts(38,22): error TS2428: All declarations of 'A' must have identical type parameters. -==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts (3 errors) ==== +==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDifferentConstraints.ts (6 errors) ==== interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. x: T; } @@ -16,6 +21,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDi module M { interface B> { + ~ +!!! error TS2428: All declarations of 'B' must have identical type parameters. x: T; } @@ -40,6 +47,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithDi module M3 { export interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. x: T; } } diff --git a/tests/baselines/reference/twoGenericInterfacesWithTheSameNameButDifferentArity.errors.txt b/tests/baselines/reference/twoGenericInterfacesWithTheSameNameButDifferentArity.errors.txt index de4c4d8e1c3..5f1b401e2a9 100644 --- a/tests/baselines/reference/twoGenericInterfacesWithTheSameNameButDifferentArity.errors.txt +++ b/tests/baselines/reference/twoGenericInterfacesWithTheSameNameButDifferentArity.errors.txt @@ -1,10 +1,15 @@ +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts(1,11): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts(5,11): error TS2428: All declarations of 'A' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts(10,15): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts(14,15): error TS2428: All declarations of 'A' must have identical type parameters. +tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts(32,22): error TS2428: All declarations of 'A' must have identical type parameters. tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts(38,22): error TS2428: All declarations of 'A' must have identical type parameters. -==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts (3 errors) ==== +==== tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTheSameNameButDifferentArity.ts (6 errors) ==== interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. x: T; } @@ -16,6 +21,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTh module M { interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. x: T; } @@ -40,6 +47,8 @@ tests/cases/conformance/interfaces/declarationMerging/twoGenericInterfacesWithTh module M3 { export interface A { + ~ +!!! error TS2428: All declarations of 'A' must have identical type parameters. x: T; } }