mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 02:21:30 -05:00
Merge pull request #5290 from Microsoft/interfaceClassMergingFix
Do not report errors for classes and interfaces merging
This commit is contained in:
@@ -12875,11 +12875,6 @@ namespace ts {
|
||||
}
|
||||
checkClassLikeDeclaration(node);
|
||||
|
||||
// Interfaces cannot be merged with non-ambient classes.
|
||||
if (getSymbolOfNode(node).flags & SymbolFlags.Interface && !isInAmbientContext(node)) {
|
||||
error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
|
||||
}
|
||||
|
||||
forEach(node.members, checkSourceElement);
|
||||
}
|
||||
|
||||
@@ -13165,16 +13160,6 @@ namespace ts {
|
||||
checkIndexConstraints(type);
|
||||
}
|
||||
}
|
||||
|
||||
// Interfaces cannot merge with non-ambient classes.
|
||||
if (symbol && symbol.declarations) {
|
||||
for (let declaration of symbol.declarations) {
|
||||
if (declaration.kind === SyntaxKind.ClassDeclaration && !isInAmbientContext(declaration)) {
|
||||
error(node, Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
forEach(getInterfaceBaseTypeNodes(node), heritageElement => {
|
||||
if (!isSupportedExpressionWithTypeArguments(heritageElement)) {
|
||||
|
||||
@@ -1620,10 +1620,6 @@
|
||||
"category": "Error",
|
||||
"code":2517
|
||||
},
|
||||
"Only an ambient class can be merged with an interface.": {
|
||||
"category": "Error",
|
||||
"code": 2518
|
||||
},
|
||||
"Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": {
|
||||
"category": "Error",
|
||||
"code": 2520
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'.
|
||||
tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesClass2.ts (4 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesClass2.ts (2 errors) ====
|
||||
// Checking class with other things in type space not value space
|
||||
|
||||
// class then interface
|
||||
class c11 { // error
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class c11 {
|
||||
foo() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
interface c11 { // error
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface c11 {
|
||||
bar(): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
// Checking class with other things in type space not value space
|
||||
|
||||
// class then interface
|
||||
class c11 { // error
|
||||
class c11 {
|
||||
foo() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
interface c11 { // error
|
||||
interface c11 {
|
||||
bar(): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'.
|
||||
tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesInterface.ts (4 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesInterface.ts (2 errors) ====
|
||||
// interface then interface
|
||||
|
||||
interface i {
|
||||
@@ -16,15 +14,11 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i
|
||||
}
|
||||
|
||||
// interface then class
|
||||
interface i2 { // error
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface i2 {
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
class i2 { // error
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class i2 {
|
||||
bar() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ interface i {
|
||||
}
|
||||
|
||||
// interface then class
|
||||
interface i2 { // error
|
||||
interface i2 {
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
class i2 { // error
|
||||
class i2 {
|
||||
bar() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(7,16): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(8,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(10,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(11,16): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(13,16): error TS2300: Duplicate identifier 'CC1'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(14,7): error TS2300: Duplicate identifier 'CC1'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(16,7): error TS2300: Duplicate identifier 'CC2'.
|
||||
@@ -20,7 +16,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(39,1): error TS2511: Cannot create an instance of the abstract class 'DCC1'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts (20 errors) ====
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts (16 errors) ====
|
||||
abstract class CM {}
|
||||
module CM {}
|
||||
|
||||
@@ -28,18 +24,10 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
|
||||
abstract class MC {}
|
||||
|
||||
abstract class CI {}
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface CI {}
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
interface IC {}
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
abstract class IC {}
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
abstract class CC1 {}
|
||||
~~~
|
||||
|
||||
@@ -1,37 +1,25 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,11): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,15): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(6,9): error TS2300: Duplicate identifier 'bar'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(10,9): error TS2300: Duplicate identifier 'bar'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (8 errors) ====
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (4 errors) ====
|
||||
class C { foo: string; }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
interface C { foo: string; } // error
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface C { foo: string; }
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
module M {
|
||||
class D {
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
bar: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
}
|
||||
|
||||
interface D { // error
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface D {
|
||||
bar: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
//// [classAndInterfaceWithSameName.ts]
|
||||
class C { foo: string; }
|
||||
interface C { foo: string; } // error
|
||||
interface C { foo: string; }
|
||||
|
||||
module M {
|
||||
class D {
|
||||
bar: string;
|
||||
}
|
||||
|
||||
interface D { // error
|
||||
interface D {
|
||||
bar: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
tests/cases/compiler/clinterfaces.ts(2,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(3,15): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(4,15): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(5,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(8,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(12,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(16,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/clinterfaces.ts(20,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
|
||||
==== tests/cases/compiler/clinterfaces.ts (8 errors) ====
|
||||
module M {
|
||||
class C { }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface C { }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface D { }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class D { }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
}
|
||||
|
||||
interface Foo<T> {
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
a: string;
|
||||
}
|
||||
|
||||
class Foo<T>{
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
b: number;
|
||||
}
|
||||
|
||||
class Bar<T>{
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
b: number;
|
||||
}
|
||||
|
||||
interface Bar<T> {
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
a: string;
|
||||
}
|
||||
|
||||
export = Foo;
|
||||
|
||||
52
tests/baselines/reference/clinterfaces.symbols
Normal file
52
tests/baselines/reference/clinterfaces.symbols
Normal file
@@ -0,0 +1,52 @@
|
||||
=== tests/cases/compiler/clinterfaces.ts ===
|
||||
module M {
|
||||
>M : Symbol(M, Decl(clinterfaces.ts, 0, 0))
|
||||
|
||||
class C { }
|
||||
>C : Symbol(C, Decl(clinterfaces.ts, 0, 10), Decl(clinterfaces.ts, 1, 15))
|
||||
|
||||
interface C { }
|
||||
>C : Symbol(C, Decl(clinterfaces.ts, 0, 10), Decl(clinterfaces.ts, 1, 15))
|
||||
|
||||
interface D { }
|
||||
>D : Symbol(D, Decl(clinterfaces.ts, 2, 19), Decl(clinterfaces.ts, 3, 19))
|
||||
|
||||
class D { }
|
||||
>D : Symbol(D, Decl(clinterfaces.ts, 2, 19), Decl(clinterfaces.ts, 3, 19))
|
||||
}
|
||||
|
||||
interface Foo<T> {
|
||||
>Foo : Symbol(Foo, Decl(clinterfaces.ts, 5, 1), Decl(clinterfaces.ts, 9, 1))
|
||||
>T : Symbol(T, Decl(clinterfaces.ts, 7, 14), Decl(clinterfaces.ts, 11, 10))
|
||||
|
||||
a: string;
|
||||
>a : Symbol(a, Decl(clinterfaces.ts, 7, 18))
|
||||
}
|
||||
|
||||
class Foo<T>{
|
||||
>Foo : Symbol(Foo, Decl(clinterfaces.ts, 5, 1), Decl(clinterfaces.ts, 9, 1))
|
||||
>T : Symbol(T, Decl(clinterfaces.ts, 7, 14), Decl(clinterfaces.ts, 11, 10))
|
||||
|
||||
b: number;
|
||||
>b : Symbol(b, Decl(clinterfaces.ts, 11, 13))
|
||||
}
|
||||
|
||||
class Bar<T>{
|
||||
>Bar : Symbol(Bar, Decl(clinterfaces.ts, 13, 1), Decl(clinterfaces.ts, 17, 1))
|
||||
>T : Symbol(T, Decl(clinterfaces.ts, 15, 10), Decl(clinterfaces.ts, 19, 14))
|
||||
|
||||
b: number;
|
||||
>b : Symbol(b, Decl(clinterfaces.ts, 15, 13))
|
||||
}
|
||||
|
||||
interface Bar<T> {
|
||||
>Bar : Symbol(Bar, Decl(clinterfaces.ts, 13, 1), Decl(clinterfaces.ts, 17, 1))
|
||||
>T : Symbol(T, Decl(clinterfaces.ts, 15, 10), Decl(clinterfaces.ts, 19, 14))
|
||||
|
||||
a: string;
|
||||
>a : Symbol(a, Decl(clinterfaces.ts, 19, 18))
|
||||
}
|
||||
|
||||
export = Foo;
|
||||
>Foo : Symbol(Foo, Decl(clinterfaces.ts, 5, 1), Decl(clinterfaces.ts, 9, 1))
|
||||
|
||||
52
tests/baselines/reference/clinterfaces.types
Normal file
52
tests/baselines/reference/clinterfaces.types
Normal file
@@ -0,0 +1,52 @@
|
||||
=== tests/cases/compiler/clinterfaces.ts ===
|
||||
module M {
|
||||
>M : typeof M
|
||||
|
||||
class C { }
|
||||
>C : C
|
||||
|
||||
interface C { }
|
||||
>C : C
|
||||
|
||||
interface D { }
|
||||
>D : D
|
||||
|
||||
class D { }
|
||||
>D : D
|
||||
}
|
||||
|
||||
interface Foo<T> {
|
||||
>Foo : Foo<T>
|
||||
>T : T
|
||||
|
||||
a: string;
|
||||
>a : string
|
||||
}
|
||||
|
||||
class Foo<T>{
|
||||
>Foo : Foo<T>
|
||||
>T : T
|
||||
|
||||
b: number;
|
||||
>b : number
|
||||
}
|
||||
|
||||
class Bar<T>{
|
||||
>Bar : Bar<T>
|
||||
>T : T
|
||||
|
||||
b: number;
|
||||
>b : number
|
||||
}
|
||||
|
||||
interface Bar<T> {
|
||||
>Bar : Bar<T>
|
||||
>T : T
|
||||
|
||||
a: string;
|
||||
>a : string
|
||||
}
|
||||
|
||||
export = Foo;
|
||||
>Foo : Foo<T>
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
tests/cases/compiler/declInput.ts(1,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/declInput.ts(5,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declInput.ts (2 errors) ====
|
||||
interface bar {
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
}
|
||||
|
||||
class bar {
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
public f() { return ''; }
|
||||
public g() { return {a: <bar>null, b: undefined, c: void 4 }; }
|
||||
public h(x = 4, y = null, z = '') { x++; }
|
||||
}
|
||||
|
||||
28
tests/baselines/reference/declInput.symbols
Normal file
28
tests/baselines/reference/declInput.symbols
Normal file
@@ -0,0 +1,28 @@
|
||||
=== tests/cases/compiler/declInput.ts ===
|
||||
interface bar {
|
||||
>bar : Symbol(bar, Decl(declInput.ts, 0, 0), Decl(declInput.ts, 2, 1))
|
||||
|
||||
}
|
||||
|
||||
class bar {
|
||||
>bar : Symbol(bar, Decl(declInput.ts, 0, 0), Decl(declInput.ts, 2, 1))
|
||||
|
||||
public f() { return ''; }
|
||||
>f : Symbol(f, Decl(declInput.ts, 4, 11))
|
||||
|
||||
public g() { return {a: <bar>null, b: undefined, c: void 4 }; }
|
||||
>g : Symbol(g, Decl(declInput.ts, 5, 27))
|
||||
>a : Symbol(a, Decl(declInput.ts, 6, 23))
|
||||
>bar : Symbol(bar, Decl(declInput.ts, 0, 0), Decl(declInput.ts, 2, 1))
|
||||
>b : Symbol(b, Decl(declInput.ts, 6, 36))
|
||||
>undefined : Symbol(undefined)
|
||||
>c : Symbol(c, Decl(declInput.ts, 6, 50))
|
||||
|
||||
public h(x = 4, y = null, z = '') { x++; }
|
||||
>h : Symbol(h, Decl(declInput.ts, 6, 65))
|
||||
>x : Symbol(x, Decl(declInput.ts, 7, 11))
|
||||
>y : Symbol(y, Decl(declInput.ts, 7, 17))
|
||||
>z : Symbol(z, Decl(declInput.ts, 7, 27))
|
||||
>x : Symbol(x, Decl(declInput.ts, 7, 11))
|
||||
}
|
||||
|
||||
38
tests/baselines/reference/declInput.types
Normal file
38
tests/baselines/reference/declInput.types
Normal file
@@ -0,0 +1,38 @@
|
||||
=== tests/cases/compiler/declInput.ts ===
|
||||
interface bar {
|
||||
>bar : bar
|
||||
|
||||
}
|
||||
|
||||
class bar {
|
||||
>bar : bar
|
||||
|
||||
public f() { return ''; }
|
||||
>f : () => string
|
||||
>'' : string
|
||||
|
||||
public g() { return {a: <bar>null, b: undefined, c: void 4 }; }
|
||||
>g : () => { a: bar; b: any; c: any; }
|
||||
>{a: <bar>null, b: undefined, c: void 4 } : { a: bar; b: undefined; c: undefined; }
|
||||
>a : bar
|
||||
><bar>null : bar
|
||||
>bar : bar
|
||||
>null : null
|
||||
>b : undefined
|
||||
>undefined : undefined
|
||||
>c : undefined
|
||||
>void 4 : undefined
|
||||
>4 : number
|
||||
|
||||
public h(x = 4, y = null, z = '') { x++; }
|
||||
>h : (x?: number, y?: any, z?: string) => void
|
||||
>x : number
|
||||
>4 : number
|
||||
>y : any
|
||||
>null : null
|
||||
>z : string
|
||||
>'' : string
|
||||
>x++ : number
|
||||
>x : number
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
|
||||
tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
|
||||
tests/cases/conformance/es6/modules/m2.ts(1,20): error TS2307: Cannot find module 'm1'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/modules/m1.ts (3 errors) ====
|
||||
==== tests/cases/conformance/es6/modules/m1.ts (2 errors) ====
|
||||
|
||||
export default class Decl {
|
||||
~~~~
|
||||
@@ -13,8 +12,6 @@ tests/cases/conformance/es6/modules/m2.ts(1,20): error TS2307: Cannot find modul
|
||||
|
||||
interface Decl {
|
||||
~~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
~~~~
|
||||
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
|
||||
p1: number;
|
||||
p2: number;
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts (6 errors) ====
|
||||
==== tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts (4 errors) ====
|
||||
module M {
|
||||
export interface I { }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
}
|
||||
module M {
|
||||
export class I { } // error
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
export class I { }
|
||||
}
|
||||
|
||||
module M {
|
||||
|
||||
@@ -3,7 +3,7 @@ module M {
|
||||
export interface I { }
|
||||
}
|
||||
module M {
|
||||
export class I { } // error
|
||||
export class I { }
|
||||
}
|
||||
|
||||
module M {
|
||||
@@ -60,7 +60,7 @@ var M;
|
||||
}
|
||||
return I;
|
||||
})();
|
||||
M.I = I; // error
|
||||
M.I = I;
|
||||
})(M || (M = {}));
|
||||
var M;
|
||||
(function (M) {
|
||||
|
||||
@@ -1,24 +1,16 @@
|
||||
tests/cases/compiler/file1.ts(2,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/file1.ts(3,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/file1.ts(4,7): error TS2300: Duplicate identifier 'C2'.
|
||||
tests/cases/compiler/file1.ts(5,10): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/file1.ts(9,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/file2.ts(1,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/file2.ts(2,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/file2.ts(3,10): error TS2300: Duplicate identifier 'C2'.
|
||||
tests/cases/compiler/file2.ts(4,7): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/file2.ts(7,8): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged
|
||||
tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (5 errors) ====
|
||||
==== tests/cases/compiler/file1.ts (3 errors) ====
|
||||
|
||||
interface I { }
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class C1 { }
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class C2 { }
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'C2'.
|
||||
@@ -39,13 +31,9 @@ tests/cases/compiler/file2.ts(8,16): error TS2300: Duplicate identifier 'x'.
|
||||
}
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/file2.ts (6 errors) ====
|
||||
==== tests/cases/compiler/file2.ts (4 errors) ====
|
||||
class I { } // error -- cannot merge interface with non-ambient class
|
||||
~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface C1 { } // error -- cannot merge interface with non-ambient class
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
function C2() { } // error -- cannot merge function with non-ambient class
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'C2'.
|
||||
|
||||
76
tests/baselines/reference/interfaceClassMerging.js
Normal file
76
tests/baselines/reference/interfaceClassMerging.js
Normal file
@@ -0,0 +1,76 @@
|
||||
//// [interfaceClassMerging.ts]
|
||||
interface Foo {
|
||||
method(a: number): string;
|
||||
optionalMethod?(a: number): string;
|
||||
property: string;
|
||||
optionalProperty?: string;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
additionalProperty: string;
|
||||
|
||||
additionalMethod(a: number): string {
|
||||
return this.method(0);
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
method(a: number) {
|
||||
return this.optionalProperty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
bar.method(0);
|
||||
bar.optionalMethod(1);
|
||||
bar.property;
|
||||
bar.optionalProperty;
|
||||
bar.additionalProperty;
|
||||
bar.additionalMethod(2);
|
||||
|
||||
var obj: {
|
||||
method(a: number): string;
|
||||
property: string;
|
||||
additionalProperty: string;
|
||||
additionalMethod(a: number): string;
|
||||
};
|
||||
|
||||
bar = obj;
|
||||
obj = bar;
|
||||
|
||||
|
||||
//// [interfaceClassMerging.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
Foo.prototype.additionalMethod = function (a) {
|
||||
return this.method(0);
|
||||
};
|
||||
return Foo;
|
||||
})();
|
||||
var Bar = (function (_super) {
|
||||
__extends(Bar, _super);
|
||||
function Bar() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Bar.prototype.method = function (a) {
|
||||
return this.optionalProperty;
|
||||
};
|
||||
return Bar;
|
||||
})(Foo);
|
||||
var bar = new Bar();
|
||||
bar.method(0);
|
||||
bar.optionalMethod(1);
|
||||
bar.property;
|
||||
bar.optionalProperty;
|
||||
bar.additionalProperty;
|
||||
bar.additionalMethod(2);
|
||||
var obj;
|
||||
bar = obj;
|
||||
obj = bar;
|
||||
113
tests/baselines/reference/interfaceClassMerging.symbols
Normal file
113
tests/baselines/reference/interfaceClassMerging.symbols
Normal file
@@ -0,0 +1,113 @@
|
||||
=== tests/cases/compiler/interfaceClassMerging.ts ===
|
||||
interface Foo {
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging.ts, 0, 0), Decl(interfaceClassMerging.ts, 5, 1))
|
||||
|
||||
method(a: number): string;
|
||||
>method : Symbol(method, Decl(interfaceClassMerging.ts, 0, 15))
|
||||
>a : Symbol(a, Decl(interfaceClassMerging.ts, 1, 11))
|
||||
|
||||
optionalMethod?(a: number): string;
|
||||
>optionalMethod : Symbol(optionalMethod, Decl(interfaceClassMerging.ts, 1, 30))
|
||||
>a : Symbol(a, Decl(interfaceClassMerging.ts, 2, 20))
|
||||
|
||||
property: string;
|
||||
>property : Symbol(property, Decl(interfaceClassMerging.ts, 2, 39))
|
||||
|
||||
optionalProperty?: string;
|
||||
>optionalProperty : Symbol(optionalProperty, Decl(interfaceClassMerging.ts, 3, 21))
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging.ts, 0, 0), Decl(interfaceClassMerging.ts, 5, 1))
|
||||
|
||||
additionalProperty: string;
|
||||
>additionalProperty : Symbol(additionalProperty, Decl(interfaceClassMerging.ts, 7, 11))
|
||||
|
||||
additionalMethod(a: number): string {
|
||||
>additionalMethod : Symbol(additionalMethod, Decl(interfaceClassMerging.ts, 8, 31))
|
||||
>a : Symbol(a, Decl(interfaceClassMerging.ts, 10, 21))
|
||||
|
||||
return this.method(0);
|
||||
>this.method : Symbol(method, Decl(interfaceClassMerging.ts, 0, 15))
|
||||
>this : Symbol(Foo, Decl(interfaceClassMerging.ts, 0, 0), Decl(interfaceClassMerging.ts, 5, 1))
|
||||
>method : Symbol(method, Decl(interfaceClassMerging.ts, 0, 15))
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
>Bar : Symbol(Bar, Decl(interfaceClassMerging.ts, 13, 1))
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging.ts, 0, 0), Decl(interfaceClassMerging.ts, 5, 1))
|
||||
|
||||
method(a: number) {
|
||||
>method : Symbol(method, Decl(interfaceClassMerging.ts, 15, 23))
|
||||
>a : Symbol(a, Decl(interfaceClassMerging.ts, 16, 11))
|
||||
|
||||
return this.optionalProperty;
|
||||
>this.optionalProperty : Symbol(Foo.optionalProperty, Decl(interfaceClassMerging.ts, 3, 21))
|
||||
>this : Symbol(Bar, Decl(interfaceClassMerging.ts, 13, 1))
|
||||
>optionalProperty : Symbol(Foo.optionalProperty, Decl(interfaceClassMerging.ts, 3, 21))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>Bar : Symbol(Bar, Decl(interfaceClassMerging.ts, 13, 1))
|
||||
|
||||
bar.method(0);
|
||||
>bar.method : Symbol(Bar.method, Decl(interfaceClassMerging.ts, 15, 23))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>method : Symbol(Bar.method, Decl(interfaceClassMerging.ts, 15, 23))
|
||||
|
||||
bar.optionalMethod(1);
|
||||
>bar.optionalMethod : Symbol(Foo.optionalMethod, Decl(interfaceClassMerging.ts, 1, 30))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>optionalMethod : Symbol(Foo.optionalMethod, Decl(interfaceClassMerging.ts, 1, 30))
|
||||
|
||||
bar.property;
|
||||
>bar.property : Symbol(Foo.property, Decl(interfaceClassMerging.ts, 2, 39))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>property : Symbol(Foo.property, Decl(interfaceClassMerging.ts, 2, 39))
|
||||
|
||||
bar.optionalProperty;
|
||||
>bar.optionalProperty : Symbol(Foo.optionalProperty, Decl(interfaceClassMerging.ts, 3, 21))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>optionalProperty : Symbol(Foo.optionalProperty, Decl(interfaceClassMerging.ts, 3, 21))
|
||||
|
||||
bar.additionalProperty;
|
||||
>bar.additionalProperty : Symbol(Foo.additionalProperty, Decl(interfaceClassMerging.ts, 7, 11))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>additionalProperty : Symbol(Foo.additionalProperty, Decl(interfaceClassMerging.ts, 7, 11))
|
||||
|
||||
bar.additionalMethod(2);
|
||||
>bar.additionalMethod : Symbol(Foo.additionalMethod, Decl(interfaceClassMerging.ts, 8, 31))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>additionalMethod : Symbol(Foo.additionalMethod, Decl(interfaceClassMerging.ts, 8, 31))
|
||||
|
||||
var obj: {
|
||||
>obj : Symbol(obj, Decl(interfaceClassMerging.ts, 30, 3))
|
||||
|
||||
method(a: number): string;
|
||||
>method : Symbol(method, Decl(interfaceClassMerging.ts, 30, 10))
|
||||
>a : Symbol(a, Decl(interfaceClassMerging.ts, 31, 11))
|
||||
|
||||
property: string;
|
||||
>property : Symbol(property, Decl(interfaceClassMerging.ts, 31, 30))
|
||||
|
||||
additionalProperty: string;
|
||||
>additionalProperty : Symbol(additionalProperty, Decl(interfaceClassMerging.ts, 32, 21))
|
||||
|
||||
additionalMethod(a: number): string;
|
||||
>additionalMethod : Symbol(additionalMethod, Decl(interfaceClassMerging.ts, 33, 31))
|
||||
>a : Symbol(a, Decl(interfaceClassMerging.ts, 34, 21))
|
||||
|
||||
};
|
||||
|
||||
bar = obj;
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
>obj : Symbol(obj, Decl(interfaceClassMerging.ts, 30, 3))
|
||||
|
||||
obj = bar;
|
||||
>obj : Symbol(obj, Decl(interfaceClassMerging.ts, 30, 3))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging.ts, 22, 3))
|
||||
|
||||
124
tests/baselines/reference/interfaceClassMerging.types
Normal file
124
tests/baselines/reference/interfaceClassMerging.types
Normal file
@@ -0,0 +1,124 @@
|
||||
=== tests/cases/compiler/interfaceClassMerging.ts ===
|
||||
interface Foo {
|
||||
>Foo : Foo
|
||||
|
||||
method(a: number): string;
|
||||
>method : (a: number) => string
|
||||
>a : number
|
||||
|
||||
optionalMethod?(a: number): string;
|
||||
>optionalMethod : (a: number) => string
|
||||
>a : number
|
||||
|
||||
property: string;
|
||||
>property : string
|
||||
|
||||
optionalProperty?: string;
|
||||
>optionalProperty : string
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
additionalProperty: string;
|
||||
>additionalProperty : string
|
||||
|
||||
additionalMethod(a: number): string {
|
||||
>additionalMethod : (a: number) => string
|
||||
>a : number
|
||||
|
||||
return this.method(0);
|
||||
>this.method(0) : string
|
||||
>this.method : (a: number) => string
|
||||
>this : this
|
||||
>method : (a: number) => string
|
||||
>0 : number
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
>Bar : Bar
|
||||
>Foo : Foo
|
||||
|
||||
method(a: number) {
|
||||
>method : (a: number) => string
|
||||
>a : number
|
||||
|
||||
return this.optionalProperty;
|
||||
>this.optionalProperty : string
|
||||
>this : this
|
||||
>optionalProperty : string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
>bar : Bar
|
||||
>new Bar() : Bar
|
||||
>Bar : typeof Bar
|
||||
|
||||
bar.method(0);
|
||||
>bar.method(0) : string
|
||||
>bar.method : (a: number) => string
|
||||
>bar : Bar
|
||||
>method : (a: number) => string
|
||||
>0 : number
|
||||
|
||||
bar.optionalMethod(1);
|
||||
>bar.optionalMethod(1) : string
|
||||
>bar.optionalMethod : (a: number) => string
|
||||
>bar : Bar
|
||||
>optionalMethod : (a: number) => string
|
||||
>1 : number
|
||||
|
||||
bar.property;
|
||||
>bar.property : string
|
||||
>bar : Bar
|
||||
>property : string
|
||||
|
||||
bar.optionalProperty;
|
||||
>bar.optionalProperty : string
|
||||
>bar : Bar
|
||||
>optionalProperty : string
|
||||
|
||||
bar.additionalProperty;
|
||||
>bar.additionalProperty : string
|
||||
>bar : Bar
|
||||
>additionalProperty : string
|
||||
|
||||
bar.additionalMethod(2);
|
||||
>bar.additionalMethod(2) : string
|
||||
>bar.additionalMethod : (a: number) => string
|
||||
>bar : Bar
|
||||
>additionalMethod : (a: number) => string
|
||||
>2 : number
|
||||
|
||||
var obj: {
|
||||
>obj : { method(a: number): string; property: string; additionalProperty: string; additionalMethod(a: number): string; }
|
||||
|
||||
method(a: number): string;
|
||||
>method : (a: number) => string
|
||||
>a : number
|
||||
|
||||
property: string;
|
||||
>property : string
|
||||
|
||||
additionalProperty: string;
|
||||
>additionalProperty : string
|
||||
|
||||
additionalMethod(a: number): string;
|
||||
>additionalMethod : (a: number) => string
|
||||
>a : number
|
||||
|
||||
};
|
||||
|
||||
bar = obj;
|
||||
>bar = obj : { method(a: number): string; property: string; additionalProperty: string; additionalMethod(a: number): string; }
|
||||
>bar : Bar
|
||||
>obj : { method(a: number): string; property: string; additionalProperty: string; additionalMethod(a: number): string; }
|
||||
|
||||
obj = bar;
|
||||
>obj = bar : Bar
|
||||
>obj : { method(a: number): string; property: string; additionalProperty: string; additionalMethod(a: number): string; }
|
||||
>bar : Bar
|
||||
|
||||
66
tests/baselines/reference/interfaceClassMerging2.js
Normal file
66
tests/baselines/reference/interfaceClassMerging2.js
Normal file
@@ -0,0 +1,66 @@
|
||||
//// [interfaceClassMerging2.ts]
|
||||
interface Foo {
|
||||
interfaceFooMethod(): this;
|
||||
interfaceFooProperty: this;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
classFooProperty: this;
|
||||
|
||||
classFooMethod(): this {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface Bar {
|
||||
interfaceBarMethod(): this;
|
||||
interfaceBarProperty: this;
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
classBarProperty: this;
|
||||
|
||||
classBarMethod(): this {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod();
|
||||
|
||||
|
||||
var foo = new Foo();
|
||||
|
||||
foo = bar;
|
||||
|
||||
|
||||
//// [interfaceClassMerging2.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
Foo.prototype.classFooMethod = function () {
|
||||
return this;
|
||||
};
|
||||
return Foo;
|
||||
})();
|
||||
var Bar = (function (_super) {
|
||||
__extends(Bar, _super);
|
||||
function Bar() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Bar.prototype.classBarMethod = function () {
|
||||
return this;
|
||||
};
|
||||
return Bar;
|
||||
})(Foo);
|
||||
var bar = new Bar();
|
||||
bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod();
|
||||
var foo = new Foo();
|
||||
foo = bar;
|
||||
76
tests/baselines/reference/interfaceClassMerging2.symbols
Normal file
76
tests/baselines/reference/interfaceClassMerging2.symbols
Normal file
@@ -0,0 +1,76 @@
|
||||
=== tests/cases/compiler/interfaceClassMerging2.ts ===
|
||||
interface Foo {
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging2.ts, 0, 0), Decl(interfaceClassMerging2.ts, 3, 1))
|
||||
|
||||
interfaceFooMethod(): this;
|
||||
>interfaceFooMethod : Symbol(interfaceFooMethod, Decl(interfaceClassMerging2.ts, 0, 15))
|
||||
|
||||
interfaceFooProperty: this;
|
||||
>interfaceFooProperty : Symbol(interfaceFooProperty, Decl(interfaceClassMerging2.ts, 1, 31))
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging2.ts, 0, 0), Decl(interfaceClassMerging2.ts, 3, 1))
|
||||
|
||||
classFooProperty: this;
|
||||
>classFooProperty : Symbol(classFooProperty, Decl(interfaceClassMerging2.ts, 5, 11))
|
||||
|
||||
classFooMethod(): this {
|
||||
>classFooMethod : Symbol(classFooMethod, Decl(interfaceClassMerging2.ts, 6, 27))
|
||||
|
||||
return this;
|
||||
>this : Symbol(Foo, Decl(interfaceClassMerging2.ts, 0, 0), Decl(interfaceClassMerging2.ts, 3, 1))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface Bar {
|
||||
>Bar : Symbol(Bar, Decl(interfaceClassMerging2.ts, 11, 1), Decl(interfaceClassMerging2.ts, 17, 1))
|
||||
|
||||
interfaceBarMethod(): this;
|
||||
>interfaceBarMethod : Symbol(interfaceBarMethod, Decl(interfaceClassMerging2.ts, 14, 15))
|
||||
|
||||
interfaceBarProperty: this;
|
||||
>interfaceBarProperty : Symbol(interfaceBarProperty, Decl(interfaceClassMerging2.ts, 15, 31))
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
>Bar : Symbol(Bar, Decl(interfaceClassMerging2.ts, 11, 1), Decl(interfaceClassMerging2.ts, 17, 1))
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging2.ts, 0, 0), Decl(interfaceClassMerging2.ts, 3, 1))
|
||||
|
||||
classBarProperty: this;
|
||||
>classBarProperty : Symbol(classBarProperty, Decl(interfaceClassMerging2.ts, 19, 23))
|
||||
|
||||
classBarMethod(): this {
|
||||
>classBarMethod : Symbol(classBarMethod, Decl(interfaceClassMerging2.ts, 20, 27))
|
||||
|
||||
return this;
|
||||
>this : Symbol(Bar, Decl(interfaceClassMerging2.ts, 11, 1), Decl(interfaceClassMerging2.ts, 17, 1))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging2.ts, 28, 3))
|
||||
>Bar : Symbol(Bar, Decl(interfaceClassMerging2.ts, 11, 1), Decl(interfaceClassMerging2.ts, 17, 1))
|
||||
|
||||
bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod();
|
||||
>bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod : Symbol(Foo.classFooMethod, Decl(interfaceClassMerging2.ts, 6, 27))
|
||||
>bar.interfaceBarMethod().interfaceFooMethod().classBarMethod : Symbol(Bar.classBarMethod, Decl(interfaceClassMerging2.ts, 20, 27))
|
||||
>bar.interfaceBarMethod().interfaceFooMethod : Symbol(Foo.interfaceFooMethod, Decl(interfaceClassMerging2.ts, 0, 15))
|
||||
>bar.interfaceBarMethod : Symbol(Bar.interfaceBarMethod, Decl(interfaceClassMerging2.ts, 14, 15))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging2.ts, 28, 3))
|
||||
>interfaceBarMethod : Symbol(Bar.interfaceBarMethod, Decl(interfaceClassMerging2.ts, 14, 15))
|
||||
>interfaceFooMethod : Symbol(Foo.interfaceFooMethod, Decl(interfaceClassMerging2.ts, 0, 15))
|
||||
>classBarMethod : Symbol(Bar.classBarMethod, Decl(interfaceClassMerging2.ts, 20, 27))
|
||||
>classFooMethod : Symbol(Foo.classFooMethod, Decl(interfaceClassMerging2.ts, 6, 27))
|
||||
|
||||
|
||||
var foo = new Foo();
|
||||
>foo : Symbol(foo, Decl(interfaceClassMerging2.ts, 32, 3))
|
||||
>Foo : Symbol(Foo, Decl(interfaceClassMerging2.ts, 0, 0), Decl(interfaceClassMerging2.ts, 3, 1))
|
||||
|
||||
foo = bar;
|
||||
>foo : Symbol(foo, Decl(interfaceClassMerging2.ts, 32, 3))
|
||||
>bar : Symbol(bar, Decl(interfaceClassMerging2.ts, 28, 3))
|
||||
|
||||
83
tests/baselines/reference/interfaceClassMerging2.types
Normal file
83
tests/baselines/reference/interfaceClassMerging2.types
Normal file
@@ -0,0 +1,83 @@
|
||||
=== tests/cases/compiler/interfaceClassMerging2.ts ===
|
||||
interface Foo {
|
||||
>Foo : Foo
|
||||
|
||||
interfaceFooMethod(): this;
|
||||
>interfaceFooMethod : () => this
|
||||
|
||||
interfaceFooProperty: this;
|
||||
>interfaceFooProperty : this
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
classFooProperty: this;
|
||||
>classFooProperty : this
|
||||
|
||||
classFooMethod(): this {
|
||||
>classFooMethod : () => this
|
||||
|
||||
return this;
|
||||
>this : this
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface Bar {
|
||||
>Bar : Bar
|
||||
|
||||
interfaceBarMethod(): this;
|
||||
>interfaceBarMethod : () => this
|
||||
|
||||
interfaceBarProperty: this;
|
||||
>interfaceBarProperty : this
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
>Bar : Bar
|
||||
>Foo : Foo
|
||||
|
||||
classBarProperty: this;
|
||||
>classBarProperty : this
|
||||
|
||||
classBarMethod(): this {
|
||||
>classBarMethod : () => this
|
||||
|
||||
return this;
|
||||
>this : this
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
>bar : Bar
|
||||
>new Bar() : Bar
|
||||
>Bar : typeof Bar
|
||||
|
||||
bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod();
|
||||
>bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod() : Bar
|
||||
>bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod : () => Bar
|
||||
>bar.interfaceBarMethod().interfaceFooMethod().classBarMethod() : Bar
|
||||
>bar.interfaceBarMethod().interfaceFooMethod().classBarMethod : () => Bar
|
||||
>bar.interfaceBarMethod().interfaceFooMethod() : Bar
|
||||
>bar.interfaceBarMethod().interfaceFooMethod : () => Bar
|
||||
>bar.interfaceBarMethod() : Bar
|
||||
>bar.interfaceBarMethod : () => Bar
|
||||
>bar : Bar
|
||||
>interfaceBarMethod : () => Bar
|
||||
>interfaceFooMethod : () => Bar
|
||||
>classBarMethod : () => Bar
|
||||
>classFooMethod : () => Bar
|
||||
|
||||
|
||||
var foo = new Foo();
|
||||
>foo : Foo
|
||||
>new Foo() : Foo
|
||||
>Foo : typeof Foo
|
||||
|
||||
foo = bar;
|
||||
>foo = bar : Bar
|
||||
>foo : Foo
|
||||
>bar : Bar
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
tests/cases/compiler/interfaceDeclaration2.ts(4,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/interfaceDeclaration2.ts(5,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
|
||||
==== tests/cases/compiler/interfaceDeclaration2.ts (2 errors) ====
|
||||
interface I1 { }
|
||||
module I1 { }
|
||||
|
||||
interface I2 { }
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class I2 { }
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
interface I3 { }
|
||||
function I3() { }
|
||||
|
||||
interface I4 { }
|
||||
var I4:number;
|
||||
|
||||
|
||||
26
tests/baselines/reference/interfaceDeclaration2.symbols
Normal file
26
tests/baselines/reference/interfaceDeclaration2.symbols
Normal file
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/compiler/interfaceDeclaration2.ts ===
|
||||
interface I1 { }
|
||||
>I1 : Symbol(I1, Decl(interfaceDeclaration2.ts, 0, 0), Decl(interfaceDeclaration2.ts, 0, 16))
|
||||
|
||||
module I1 { }
|
||||
>I1 : Symbol(I1, Decl(interfaceDeclaration2.ts, 0, 0), Decl(interfaceDeclaration2.ts, 0, 16))
|
||||
|
||||
interface I2 { }
|
||||
>I2 : Symbol(I2, Decl(interfaceDeclaration2.ts, 1, 13), Decl(interfaceDeclaration2.ts, 3, 16))
|
||||
|
||||
class I2 { }
|
||||
>I2 : Symbol(I2, Decl(interfaceDeclaration2.ts, 1, 13), Decl(interfaceDeclaration2.ts, 3, 16))
|
||||
|
||||
interface I3 { }
|
||||
>I3 : Symbol(I3, Decl(interfaceDeclaration2.ts, 4, 12), Decl(interfaceDeclaration2.ts, 6, 16))
|
||||
|
||||
function I3() { }
|
||||
>I3 : Symbol(I3, Decl(interfaceDeclaration2.ts, 4, 12), Decl(interfaceDeclaration2.ts, 6, 16))
|
||||
|
||||
interface I4 { }
|
||||
>I4 : Symbol(I4, Decl(interfaceDeclaration2.ts, 7, 17), Decl(interfaceDeclaration2.ts, 10, 3))
|
||||
|
||||
var I4:number;
|
||||
>I4 : Symbol(I4, Decl(interfaceDeclaration2.ts, 7, 17), Decl(interfaceDeclaration2.ts, 10, 3))
|
||||
|
||||
|
||||
26
tests/baselines/reference/interfaceDeclaration2.types
Normal file
26
tests/baselines/reference/interfaceDeclaration2.types
Normal file
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/compiler/interfaceDeclaration2.ts ===
|
||||
interface I1 { }
|
||||
>I1 : I1
|
||||
|
||||
module I1 { }
|
||||
>I1 : any
|
||||
|
||||
interface I2 { }
|
||||
>I2 : I2
|
||||
|
||||
class I2 { }
|
||||
>I2 : I2
|
||||
|
||||
interface I3 { }
|
||||
>I3 : I3
|
||||
|
||||
function I3() { }
|
||||
>I3 : () => void
|
||||
|
||||
interface I4 { }
|
||||
>I4 : I4
|
||||
|
||||
var I4:number;
|
||||
>I4 : number
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
tests/cases/conformance/classes/classDeclarations/file1.ts(11,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/file1.ts(13,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/file1.ts(15,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/conformance/classes/classDeclarations/file1.ts(17,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/file1.ts (4 errors) ====
|
||||
|
||||
|
||||
declare class C1 { }
|
||||
|
||||
interface C1 { }
|
||||
|
||||
interface C2 { }
|
||||
|
||||
declare class C2 { }
|
||||
|
||||
class C3 { } // error -- cannot merge non-ambient class and interface
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
interface C3 { } // error -- cannot merge non-ambient class and interface
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
interface C4 { } // error -- cannot merge non-ambient class and interface
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
class C4 { } // error -- cannot merge non-ambient class and interface
|
||||
~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
interface C5 {
|
||||
x1: number;
|
||||
}
|
||||
|
||||
declare class C5 {
|
||||
x2: number;
|
||||
}
|
||||
|
||||
interface C5 {
|
||||
x3: number;
|
||||
}
|
||||
|
||||
interface C5 {
|
||||
x4: number;
|
||||
}
|
||||
|
||||
// checks if properties actually were merged
|
||||
var c5 : C5;
|
||||
c5.x1;
|
||||
c5.x2;
|
||||
c5.x3;
|
||||
c5.x4;
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/file2.ts (0 errors) ====
|
||||
|
||||
declare class C6 { }
|
||||
|
||||
interface C7 { }
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/file3.ts (0 errors) ====
|
||||
|
||||
interface C6 { }
|
||||
|
||||
declare class C7 { }
|
||||
@@ -11,13 +11,13 @@ interface C2 { }
|
||||
|
||||
declare class C2 { }
|
||||
|
||||
class C3 { } // error -- cannot merge non-ambient class and interface
|
||||
class C3 { }
|
||||
|
||||
interface C3 { } // error -- cannot merge non-ambient class and interface
|
||||
interface C3 { }
|
||||
|
||||
interface C4 { } // error -- cannot merge non-ambient class and interface
|
||||
interface C4 { }
|
||||
|
||||
class C4 { } // error -- cannot merge non-ambient class and interface
|
||||
class C4 { }
|
||||
|
||||
interface C5 {
|
||||
x1: number;
|
||||
@@ -59,12 +59,12 @@ var C3 = (function () {
|
||||
function C3() {
|
||||
}
|
||||
return C3;
|
||||
})(); // error -- cannot merge non-ambient class and interface
|
||||
})();
|
||||
var C4 = (function () {
|
||||
function C4() {
|
||||
}
|
||||
return C4;
|
||||
})(); // error -- cannot merge non-ambient class and interface
|
||||
})();
|
||||
// checks if properties actually were merged
|
||||
var c5;
|
||||
c5.x1;
|
||||
|
||||
96
tests/baselines/reference/mergedClassInterface.symbols
Normal file
96
tests/baselines/reference/mergedClassInterface.symbols
Normal file
@@ -0,0 +1,96 @@
|
||||
=== tests/cases/conformance/classes/classDeclarations/file1.ts ===
|
||||
|
||||
|
||||
declare class C1 { }
|
||||
>C1 : Symbol(C1, Decl(file1.ts, 0, 0), Decl(file1.ts, 2, 20))
|
||||
|
||||
interface C1 { }
|
||||
>C1 : Symbol(C1, Decl(file1.ts, 0, 0), Decl(file1.ts, 2, 20))
|
||||
|
||||
interface C2 { }
|
||||
>C2 : Symbol(C2, Decl(file1.ts, 4, 16), Decl(file1.ts, 6, 16))
|
||||
|
||||
declare class C2 { }
|
||||
>C2 : Symbol(C2, Decl(file1.ts, 4, 16), Decl(file1.ts, 6, 16))
|
||||
|
||||
class C3 { }
|
||||
>C3 : Symbol(C3, Decl(file1.ts, 8, 20), Decl(file1.ts, 10, 12))
|
||||
|
||||
interface C3 { }
|
||||
>C3 : Symbol(C3, Decl(file1.ts, 8, 20), Decl(file1.ts, 10, 12))
|
||||
|
||||
interface C4 { }
|
||||
>C4 : Symbol(C4, Decl(file1.ts, 12, 16), Decl(file1.ts, 14, 16))
|
||||
|
||||
class C4 { }
|
||||
>C4 : Symbol(C4, Decl(file1.ts, 12, 16), Decl(file1.ts, 14, 16))
|
||||
|
||||
interface C5 {
|
||||
>C5 : Symbol(C5, Decl(file1.ts, 16, 12), Decl(file1.ts, 20, 1), Decl(file1.ts, 24, 1), Decl(file1.ts, 28, 1))
|
||||
|
||||
x1: number;
|
||||
>x1 : Symbol(x1, Decl(file1.ts, 18, 14))
|
||||
}
|
||||
|
||||
declare class C5 {
|
||||
>C5 : Symbol(C5, Decl(file1.ts, 16, 12), Decl(file1.ts, 20, 1), Decl(file1.ts, 24, 1), Decl(file1.ts, 28, 1))
|
||||
|
||||
x2: number;
|
||||
>x2 : Symbol(x2, Decl(file1.ts, 22, 18))
|
||||
}
|
||||
|
||||
interface C5 {
|
||||
>C5 : Symbol(C5, Decl(file1.ts, 16, 12), Decl(file1.ts, 20, 1), Decl(file1.ts, 24, 1), Decl(file1.ts, 28, 1))
|
||||
|
||||
x3: number;
|
||||
>x3 : Symbol(x3, Decl(file1.ts, 26, 14))
|
||||
}
|
||||
|
||||
interface C5 {
|
||||
>C5 : Symbol(C5, Decl(file1.ts, 16, 12), Decl(file1.ts, 20, 1), Decl(file1.ts, 24, 1), Decl(file1.ts, 28, 1))
|
||||
|
||||
x4: number;
|
||||
>x4 : Symbol(x4, Decl(file1.ts, 30, 14))
|
||||
}
|
||||
|
||||
// checks if properties actually were merged
|
||||
var c5 : C5;
|
||||
>c5 : Symbol(c5, Decl(file1.ts, 35, 3))
|
||||
>C5 : Symbol(C5, Decl(file1.ts, 16, 12), Decl(file1.ts, 20, 1), Decl(file1.ts, 24, 1), Decl(file1.ts, 28, 1))
|
||||
|
||||
c5.x1;
|
||||
>c5.x1 : Symbol(C5.x1, Decl(file1.ts, 18, 14))
|
||||
>c5 : Symbol(c5, Decl(file1.ts, 35, 3))
|
||||
>x1 : Symbol(C5.x1, Decl(file1.ts, 18, 14))
|
||||
|
||||
c5.x2;
|
||||
>c5.x2 : Symbol(C5.x2, Decl(file1.ts, 22, 18))
|
||||
>c5 : Symbol(c5, Decl(file1.ts, 35, 3))
|
||||
>x2 : Symbol(C5.x2, Decl(file1.ts, 22, 18))
|
||||
|
||||
c5.x3;
|
||||
>c5.x3 : Symbol(C5.x3, Decl(file1.ts, 26, 14))
|
||||
>c5 : Symbol(c5, Decl(file1.ts, 35, 3))
|
||||
>x3 : Symbol(C5.x3, Decl(file1.ts, 26, 14))
|
||||
|
||||
c5.x4;
|
||||
>c5.x4 : Symbol(C5.x4, Decl(file1.ts, 30, 14))
|
||||
>c5 : Symbol(c5, Decl(file1.ts, 35, 3))
|
||||
>x4 : Symbol(C5.x4, Decl(file1.ts, 30, 14))
|
||||
|
||||
=== tests/cases/conformance/classes/classDeclarations/file2.ts ===
|
||||
|
||||
declare class C6 { }
|
||||
>C6 : Symbol(C6, Decl(file2.ts, 0, 0), Decl(file3.ts, 0, 0))
|
||||
|
||||
interface C7 { }
|
||||
>C7 : Symbol(C7, Decl(file2.ts, 1, 20), Decl(file3.ts, 1, 16))
|
||||
|
||||
=== tests/cases/conformance/classes/classDeclarations/file3.ts ===
|
||||
|
||||
interface C6 { }
|
||||
>C6 : Symbol(C6, Decl(file2.ts, 0, 0), Decl(file3.ts, 0, 0))
|
||||
|
||||
declare class C7 { }
|
||||
>C7 : Symbol(C7, Decl(file2.ts, 1, 20), Decl(file3.ts, 1, 16))
|
||||
|
||||
96
tests/baselines/reference/mergedClassInterface.types
Normal file
96
tests/baselines/reference/mergedClassInterface.types
Normal file
@@ -0,0 +1,96 @@
|
||||
=== tests/cases/conformance/classes/classDeclarations/file1.ts ===
|
||||
|
||||
|
||||
declare class C1 { }
|
||||
>C1 : C1
|
||||
|
||||
interface C1 { }
|
||||
>C1 : C1
|
||||
|
||||
interface C2 { }
|
||||
>C2 : C2
|
||||
|
||||
declare class C2 { }
|
||||
>C2 : C2
|
||||
|
||||
class C3 { }
|
||||
>C3 : C3
|
||||
|
||||
interface C3 { }
|
||||
>C3 : C3
|
||||
|
||||
interface C4 { }
|
||||
>C4 : C4
|
||||
|
||||
class C4 { }
|
||||
>C4 : C4
|
||||
|
||||
interface C5 {
|
||||
>C5 : C5
|
||||
|
||||
x1: number;
|
||||
>x1 : number
|
||||
}
|
||||
|
||||
declare class C5 {
|
||||
>C5 : C5
|
||||
|
||||
x2: number;
|
||||
>x2 : number
|
||||
}
|
||||
|
||||
interface C5 {
|
||||
>C5 : C5
|
||||
|
||||
x3: number;
|
||||
>x3 : number
|
||||
}
|
||||
|
||||
interface C5 {
|
||||
>C5 : C5
|
||||
|
||||
x4: number;
|
||||
>x4 : number
|
||||
}
|
||||
|
||||
// checks if properties actually were merged
|
||||
var c5 : C5;
|
||||
>c5 : C5
|
||||
>C5 : C5
|
||||
|
||||
c5.x1;
|
||||
>c5.x1 : number
|
||||
>c5 : C5
|
||||
>x1 : number
|
||||
|
||||
c5.x2;
|
||||
>c5.x2 : number
|
||||
>c5 : C5
|
||||
>x2 : number
|
||||
|
||||
c5.x3;
|
||||
>c5.x3 : number
|
||||
>c5 : C5
|
||||
>x3 : number
|
||||
|
||||
c5.x4;
|
||||
>c5.x4 : number
|
||||
>c5 : C5
|
||||
>x4 : number
|
||||
|
||||
=== tests/cases/conformance/classes/classDeclarations/file2.ts ===
|
||||
|
||||
declare class C6 { }
|
||||
>C6 : C6
|
||||
|
||||
interface C7 { }
|
||||
>C7 : C7
|
||||
|
||||
=== tests/cases/conformance/classes/classDeclarations/file3.ts ===
|
||||
|
||||
interface C6 { }
|
||||
>C6 : C6
|
||||
|
||||
declare class C7 { }
|
||||
>C7 : C7
|
||||
|
||||
@@ -11,13 +11,9 @@ tests/cases/compiler/nameCollisions.ts(33,11): error TS2300: Duplicate identifie
|
||||
tests/cases/compiler/nameCollisions.ts(34,14): error TS2300: Duplicate identifier 'C'.
|
||||
tests/cases/compiler/nameCollisions.ts(36,14): error TS2300: Duplicate identifier 'C2'.
|
||||
tests/cases/compiler/nameCollisions.ts(37,11): error TS2300: Duplicate identifier 'C2'.
|
||||
tests/cases/compiler/nameCollisions.ts(42,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/nameCollisions.ts(43,15): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/nameCollisions.ts(45,15): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/nameCollisions.ts(46,11): error TS2518: Only an ambient class can be merged with an interface.
|
||||
|
||||
|
||||
==== tests/cases/compiler/nameCollisions.ts (17 errors) ====
|
||||
==== tests/cases/compiler/nameCollisions.ts (13 errors) ====
|
||||
module T {
|
||||
var x = 2;
|
||||
~
|
||||
@@ -86,16 +82,8 @@ tests/cases/compiler/nameCollisions.ts(46,11): error TS2518: Only an ambient cla
|
||||
interface fi { } // ok
|
||||
|
||||
class cli { }
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface cli { } // error
|
||||
~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
interface cli { }
|
||||
|
||||
interface cli2 { }
|
||||
~~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class cli2 { } // error
|
||||
~~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
class cli2 { }
|
||||
}
|
||||
@@ -41,10 +41,10 @@ module T {
|
||||
interface fi { } // ok
|
||||
|
||||
class cli { }
|
||||
interface cli { } // error
|
||||
interface cli { }
|
||||
|
||||
interface cli2 { }
|
||||
class cli2 { } // error
|
||||
class cli2 { }
|
||||
}
|
||||
|
||||
//// [nameCollisions.js]
|
||||
@@ -102,5 +102,5 @@ var T;
|
||||
function cli2() {
|
||||
}
|
||||
return cli2;
|
||||
})(); // error
|
||||
})();
|
||||
})(T || (T = {}));
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'.
|
||||
Property 'raw' is missing in type '{}'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (2 errors) ====
|
||||
==== tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts (1 errors) ====
|
||||
|
||||
class TemplateStringsArray {
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
}
|
||||
|
||||
function f(x: TemplateStringsArray, y: number, z: number) {
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2518: Only an ambient class can be merged with an interface.
|
||||
tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{}' is not assignable to parameter of type 'TemplateStringsArray'.
|
||||
Property 'raw' is missing in type '{}'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts (2 errors) ====
|
||||
==== tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts (1 errors) ====
|
||||
|
||||
class TemplateStringsArray {
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2518: Only an ambient class can be merged with an interface.
|
||||
}
|
||||
|
||||
function f(x: TemplateStringsArray, y: number, z: number) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Checking class with other things in type space not value space
|
||||
|
||||
// class then interface
|
||||
class c11 { // error
|
||||
class c11 {
|
||||
foo() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
interface c11 { // error
|
||||
interface c11 {
|
||||
bar(): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@ interface i {
|
||||
}
|
||||
|
||||
// interface then class
|
||||
interface i2 { // error
|
||||
interface i2 {
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
class i2 { // error
|
||||
class i2 {
|
||||
bar() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ module M {
|
||||
export interface I { }
|
||||
}
|
||||
module M {
|
||||
export class I { } // error
|
||||
export class I { }
|
||||
}
|
||||
|
||||
module M {
|
||||
|
||||
39
tests/cases/compiler/interfaceClassMerging.ts
Normal file
39
tests/cases/compiler/interfaceClassMerging.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
interface Foo {
|
||||
method(a: number): string;
|
||||
optionalMethod?(a: number): string;
|
||||
property: string;
|
||||
optionalProperty?: string;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
additionalProperty: string;
|
||||
|
||||
additionalMethod(a: number): string {
|
||||
return this.method(0);
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
method(a: number) {
|
||||
return this.optionalProperty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
bar.method(0);
|
||||
bar.optionalMethod(1);
|
||||
bar.property;
|
||||
bar.optionalProperty;
|
||||
bar.additionalProperty;
|
||||
bar.additionalMethod(2);
|
||||
|
||||
var obj: {
|
||||
method(a: number): string;
|
||||
property: string;
|
||||
additionalProperty: string;
|
||||
additionalMethod(a: number): string;
|
||||
};
|
||||
|
||||
bar = obj;
|
||||
obj = bar;
|
||||
35
tests/cases/compiler/interfaceClassMerging2.ts
Normal file
35
tests/cases/compiler/interfaceClassMerging2.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
interface Foo {
|
||||
interfaceFooMethod(): this;
|
||||
interfaceFooProperty: this;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
classFooProperty: this;
|
||||
|
||||
classFooMethod(): this {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface Bar {
|
||||
interfaceBarMethod(): this;
|
||||
interfaceBarProperty: this;
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
classBarProperty: this;
|
||||
|
||||
classBarMethod(): this {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var bar = new Bar();
|
||||
bar.interfaceBarMethod().interfaceFooMethod().classBarMethod().classFooMethod();
|
||||
|
||||
|
||||
var foo = new Foo();
|
||||
|
||||
foo = bar;
|
||||
@@ -40,8 +40,8 @@ module T {
|
||||
interface fi { } // ok
|
||||
|
||||
class cli { }
|
||||
interface cli { } // error
|
||||
interface cli { }
|
||||
|
||||
interface cli2 { }
|
||||
class cli2 { } // error
|
||||
class cli2 { }
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
class C { foo: string; }
|
||||
interface C { foo: string; } // error
|
||||
interface C { foo: string; }
|
||||
|
||||
module M {
|
||||
class D {
|
||||
bar: string;
|
||||
}
|
||||
|
||||
interface D { // error
|
||||
interface D {
|
||||
bar: string;
|
||||
}
|
||||
}
|
||||
@@ -10,13 +10,13 @@ interface C2 { }
|
||||
|
||||
declare class C2 { }
|
||||
|
||||
class C3 { } // error -- cannot merge non-ambient class and interface
|
||||
class C3 { }
|
||||
|
||||
interface C3 { } // error -- cannot merge non-ambient class and interface
|
||||
interface C3 { }
|
||||
|
||||
interface C4 { } // error -- cannot merge non-ambient class and interface
|
||||
interface C4 { }
|
||||
|
||||
class C4 { } // error -- cannot merge non-ambient class and interface
|
||||
class C4 { }
|
||||
|
||||
interface C5 {
|
||||
x1: number;
|
||||
|
||||
Reference in New Issue
Block a user