Simplify checkTypeParameterListsIdentical

This commit is contained in:
Ron Buckton 2017-02-03 16:34:42 -08:00
parent 6ffcbf5b9c
commit 5bb2fe03ea
13 changed files with 152 additions and 110 deletions

View File

@ -376,7 +376,7 @@ namespace ts {
Type,
ResolvedBaseConstructorType,
DeclaredType,
ResolvedReturnType,
ResolvedReturnType
}
const builtinGlobals = createMap<Symbol>();
@ -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 = <InterfaceType>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 = (<ClassDeclaration | InterfaceDeclaration>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 = <InterfaceType>getDeclaredTypeOfSymbol(symbol);
const typeWithThis = getTypeWithThisArgument(type);
const staticType = <ObjectType>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 = <InterfaceDeclaration>getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration);

View File

@ -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)

View File

@ -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;
}

View File

@ -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<A, A> { // should error
~
!!! error TS2300: Duplicate identifier 'A'.
@ -11,6 +12,8 @@ tests/cases/compiler/extendedInterfacesWithDuplicateTypeParameters.ts(9,38): err
}
interface InterfaceWithSomeTypars<B> { // should not error
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2428: All declarations of 'InterfaceWithSomeTypars' must have identical type parameters.
bar(): void;
}

View File

@ -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<T> {
~
!!! 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;
}
}

View File

@ -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<T> { } // ok
~~~
!!! error TS2428: All declarations of 'i00' must have identical type parameters.
interface i00<U = number> { } // error
~~~
!!! error TS2428: All declarations of 'i00' must have identical type parameters.
interface i01<T = number> { } // ok
~~~
!!! error TS2428: All declarations of 'i01' must have identical type parameters.
interface i01<T = string> { } // error
~~~
!!! error TS2428: All declarations of 'i01' must have identical type parameters.

View File

@ -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<V> {
~~
!!! error TS2428: All declarations of 'I1' must have identical type parameters.
}
interface I1<S> { // Name mismatch
~~
@ -36,6 +41,8 @@ tests/cases/compiler/interfaceWithMultipleDeclarations.ts(29,11): error TS2428:
}
interface I2<T extends string> {
~~
!!! error TS2428: All declarations of 'I2' must have identical type parameters.
}
interface I2<T extends () => 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<T> { // length mismatch
~~

View File

@ -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;
~~~~~~~~~~~~~~~~~~~~

View File

@ -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<T extends Function> {
~~~
!!! error TS2428: All declarations of 'Foo' must have identical type parameters.
n: T;
}
interface Foo<T extends Different> {
@ -19,6 +24,8 @@ tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All de
y: T;
}
interface Qux<T extends Different> {
~~~
!!! error TS2428: All declarations of 'Qux' must have identical type parameters.
y: T;
}
class Qux<T extends Function> {
@ -41,6 +48,8 @@ tests/cases/compiler/nonIdenticalTypeConstraints.ts(36,11): error TS2428: All de
}
class Quux<T> {
~~~~
!!! error TS2428: All declarations of 'Quux' must have identical type parameters.
n: T;
}
interface Quux<U> {

View File

@ -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<T> {
~
!!! 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<T,U> {
~
!!! 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<T> {
~
!!! 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<T, U> {
~
!!! 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<T, U> {
~
!!! error TS2428: All declarations of 'B' must have identical type parameters.
x: U;
}
}

View File

@ -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<T, U> {
~
!!! 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<T, U> {
~
!!! 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<T, U> {
~
!!! error TS2428: All declarations of 'B' must have identical type parameters.
x: U;
}
}

View File

@ -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<T extends Date> {
~
!!! 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<T extends A<Date>> {
~
!!! 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<T extends Date> {
~
!!! error TS2428: All declarations of 'A' must have identical type parameters.
x: T;
}
}

View File

@ -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<T> {
~
!!! 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<T> {
~
!!! 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<T> {
~
!!! error TS2428: All declarations of 'A' must have identical type parameters.
x: T;
}
}