Merge branch 'master' into reachabilityChecks

This commit is contained in:
Vladimir Matveev
2015-10-19 15:54:45 -07:00
78 changed files with 44712 additions and 40862 deletions

View File

@@ -0,0 +1,12 @@
//// [ambientClassMergesOverloadsWithInterface.ts]
declare class C {
baz(): any;
foo(n: number): any;
}
interface C {
foo(n: number): any;
bar(): any;
}
//// [ambientClassMergesOverloadsWithInterface.js]

View File

@@ -0,0 +1,22 @@
=== tests/cases/compiler/ambientClassMergesOverloadsWithInterface.ts ===
declare class C {
>C : Symbol(C, Decl(ambientClassMergesOverloadsWithInterface.ts, 0, 0), Decl(ambientClassMergesOverloadsWithInterface.ts, 3, 1))
baz(): any;
>baz : Symbol(baz, Decl(ambientClassMergesOverloadsWithInterface.ts, 0, 17))
foo(n: number): any;
>foo : Symbol(foo, Decl(ambientClassMergesOverloadsWithInterface.ts, 1, 15), Decl(ambientClassMergesOverloadsWithInterface.ts, 4, 13))
>n : Symbol(n, Decl(ambientClassMergesOverloadsWithInterface.ts, 2, 8))
}
interface C {
>C : Symbol(C, Decl(ambientClassMergesOverloadsWithInterface.ts, 0, 0), Decl(ambientClassMergesOverloadsWithInterface.ts, 3, 1))
foo(n: number): any;
>foo : Symbol(foo, Decl(ambientClassMergesOverloadsWithInterface.ts, 1, 15), Decl(ambientClassMergesOverloadsWithInterface.ts, 4, 13))
>n : Symbol(n, Decl(ambientClassMergesOverloadsWithInterface.ts, 5, 8))
bar(): any;
>bar : Symbol(bar, Decl(ambientClassMergesOverloadsWithInterface.ts, 5, 24))
}

View File

@@ -0,0 +1,22 @@
=== tests/cases/compiler/ambientClassMergesOverloadsWithInterface.ts ===
declare class C {
>C : C
baz(): any;
>baz : () => any
foo(n: number): any;
>foo : { (n: number): any; (n: number): any; }
>n : number
}
interface C {
>C : C
foo(n: number): any;
>foo : { (n: number): any; (n: number): any; }
>n : number
bar(): any;
>bar : () => any
}

View File

@@ -0,0 +1,13 @@
//// [arrayBufferIsViewNarrowsType.ts]
var obj: Object;
if (ArrayBuffer.isView(obj)) {
// isView should be a guard that narrows type to ArrayBufferView.
var ab: ArrayBufferView = obj;
}
//// [arrayBufferIsViewNarrowsType.js]
var obj;
if (ArrayBuffer.isView(obj)) {
// isView should be a guard that narrows type to ArrayBufferView.
var ab = obj;
}

View File

@@ -0,0 +1,17 @@
=== tests/cases/compiler/arrayBufferIsViewNarrowsType.ts ===
var obj: Object;
>obj : Symbol(obj, Decl(arrayBufferIsViewNarrowsType.ts, 0, 3))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
if (ArrayBuffer.isView(obj)) {
>ArrayBuffer.isView : Symbol(ArrayBufferConstructor.isView, Decl(lib.d.ts, --, --))
>ArrayBuffer : Symbol(ArrayBuffer, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>isView : Symbol(ArrayBufferConstructor.isView, Decl(lib.d.ts, --, --))
>obj : Symbol(obj, Decl(arrayBufferIsViewNarrowsType.ts, 0, 3))
// isView should be a guard that narrows type to ArrayBufferView.
var ab: ArrayBufferView = obj;
>ab : Symbol(ab, Decl(arrayBufferIsViewNarrowsType.ts, 3, 7))
>ArrayBufferView : Symbol(ArrayBufferView, Decl(lib.d.ts, --, --))
>obj : Symbol(obj, Decl(arrayBufferIsViewNarrowsType.ts, 0, 3))
}

View File

@@ -0,0 +1,18 @@
=== tests/cases/compiler/arrayBufferIsViewNarrowsType.ts ===
var obj: Object;
>obj : Object
>Object : Object
if (ArrayBuffer.isView(obj)) {
>ArrayBuffer.isView(obj) : boolean
>ArrayBuffer.isView : (arg: any) => arg is ArrayBufferView
>ArrayBuffer : ArrayBufferConstructor
>isView : (arg: any) => arg is ArrayBufferView
>obj : Object
// isView should be a guard that narrows type to ArrayBufferView.
var ab: ArrayBufferView = obj;
>ab : ArrayBufferView
>ArrayBufferView : ArrayBufferView
>obj : ArrayBufferView
}

View File

@@ -2,9 +2,13 @@ tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [index: st
Property 'one' is missing in type '{ [index: string]: any; }'.
tests/cases/compiler/assignmentCompat1.ts(6,1): error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'.
Property 'one' is missing in type '{ [index: number]: any; }'.
tests/cases/compiler/assignmentCompat1.ts(8,1): error TS2322: Type 'string' is not assignable to type '{ [index: string]: any; }'.
Index signature is missing in type 'String'.
tests/cases/compiler/assignmentCompat1.ts(10,1): error TS2322: Type 'boolean' is not assignable to type '{ [index: number]: any; }'.
Index signature is missing in type 'Boolean'.
==== tests/cases/compiler/assignmentCompat1.ts (2 errors) ====
==== tests/cases/compiler/assignmentCompat1.ts (4 errors) ====
var x = { one: 1 };
var y: { [index: string]: any };
var z: { [index: number]: any };
@@ -18,4 +22,14 @@ tests/cases/compiler/assignmentCompat1.ts(6,1): error TS2322: Type '{ [index: nu
!!! error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'.
!!! error TS2322: Property 'one' is missing in type '{ [index: number]: any; }'.
z = x; // Ok because index signature type is any
y = "foo"; // Error
~
!!! error TS2322: Type 'string' is not assignable to type '{ [index: string]: any; }'.
!!! error TS2322: Index signature is missing in type 'String'.
z = "foo"; // OK, string has numeric indexer
z = false; // Error
~
!!! error TS2322: Type 'boolean' is not assignable to type '{ [index: number]: any; }'.
!!! error TS2322: Index signature is missing in type 'Boolean'.

View File

@@ -6,6 +6,10 @@ x = y; // Error
y = x; // Ok because index signature type is any
x = z; // Error
z = x; // Ok because index signature type is any
y = "foo"; // Error
z = "foo"; // OK, string has numeric indexer
z = false; // Error
//// [assignmentCompat1.js]
@@ -16,3 +20,6 @@ x = y; // Error
y = x; // Ok because index signature type is any
x = z; // Error
z = x; // Ok because index signature type is any
y = "foo"; // Error
z = "foo"; // OK, string has numeric indexer
z = false; // Error

View File

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

View File

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

View File

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

View File

@@ -10,11 +10,11 @@ interface i {
}
// interface then class
interface i2 { // error
interface i2 {
foo(): void;
}
class i2 { // error
class i2 {
bar() {
return 1;
}

View File

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

View File

@@ -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'.

View File

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

View File

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

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

View 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>

View File

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

View 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))
}

View 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
}

View File

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

View File

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

View File

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

View File

@@ -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'.

View File

@@ -1,13 +1,14 @@
tests/cases/compiler/indexTypeCheck.ts(2,2): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/indexTypeCheck.ts(3,2): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/indexTypeCheck.ts(17,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'.
tests/cases/compiler/indexTypeCheck.ts(22,2): error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'.
tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'.
tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
==== tests/cases/compiler/indexTypeCheck.ts (7 errors) ====
==== tests/cases/compiler/indexTypeCheck.ts (8 errors) ====
interface Red {
[n:number]; // ok
~~~~~~~~~~~
@@ -36,6 +37,8 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression
interface Green {
[n:number]: Orange; // error
~~~~~~~~~~~~~~~~~~~
!!! error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'.
[s:string]: Yellow; // ok
}

View File

@@ -30,6 +30,8 @@ tests/cases/compiler/intTypeCheck.ts(134,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(134,22): error TS2304: Cannot find name 'i3'.
tests/cases/compiler/intTypeCheck.ts(135,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(142,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(148,5): error TS2322: Type 'boolean' is not assignable to type 'i4'.
Index signature is missing in type 'Boolean'.
tests/cases/compiler/intTypeCheck.ts(148,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(148,22): error TS2304: Cannot find name 'i4'.
tests/cases/compiler/intTypeCheck.ts(149,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
@@ -66,12 +68,14 @@ tests/cases/compiler/intTypeCheck.ts(190,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(190,22): error TS2304: Cannot find name 'i7'.
tests/cases/compiler/intTypeCheck.ts(191,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(198,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(204,5): error TS2322: Type 'boolean' is not assignable to type 'i8'.
Index signature is missing in type 'Boolean'.
tests/cases/compiler/intTypeCheck.ts(204,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(204,22): error TS2304: Cannot find name 'i8'.
tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
==== tests/cases/compiler/intTypeCheck.ts (61 errors) ====
==== tests/cases/compiler/intTypeCheck.ts (63 errors) ====
interface i1 {
//Property Signatures
p;
@@ -280,6 +284,9 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
//var obj40: i4 = function foo() { };
var obj41: i4 = <i4> anyVar;
var obj42: i4 = new <i4> anyVar;
~~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'i4'.
!!! error TS2322: Index signature is missing in type 'Boolean'.
~
!!! error TS1109: Expression expected.
~~
@@ -402,6 +409,9 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
//var obj84: i8 = function foo() { };
var obj85: i8 = <i8> anyVar;
var obj86: i8 = new <i8> anyVar;
~~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'i8'.
!!! error TS2322: Index signature is missing in type 'Boolean'.
~
!!! error TS1109: Expression expected.
~~

View 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;

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

View 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

View 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;

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

View 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

View File

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

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

View 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

View File

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

View File

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

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

View 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

View File

@@ -0,0 +1,38 @@
//// [tests/cases/compiler/moduleMergeConstructor.ts] ////
//// [foo.d.ts]
declare module "foo" {
export class Foo {
constructor();
method1(): any;
}
}
//// [foo-ext.d.ts]
declare module "foo" {
export interface Foo {
method2(): any;
}
}
//// [index.ts]
import * as foo from "foo";
class Test {
bar: foo.Foo;
constructor() {
this.bar = new foo.Foo();
}
}
//// [index.js]
define(["require", "exports", "foo"], function (require, exports, foo) {
var Test = (function () {
function Test() {
this.bar = new foo.Foo();
}
return Test;
})();
});

View File

@@ -0,0 +1,45 @@
=== tests/cases/compiler/foo.d.ts ===
declare module "foo" {
export class Foo {
>Foo : Symbol(Foo, Decl(foo.d.ts, 1, 22), Decl(foo-ext.d.ts, 0, 22))
constructor();
method1(): any;
>method1 : Symbol(method1, Decl(foo.d.ts, 3, 22))
}
}
=== tests/cases/compiler/foo-ext.d.ts ===
declare module "foo" {
export interface Foo {
>Foo : Symbol(Foo, Decl(foo.d.ts, 1, 22), Decl(foo-ext.d.ts, 0, 22))
method2(): any;
>method2 : Symbol(method2, Decl(foo-ext.d.ts, 1, 26))
}
}
=== tests/cases/compiler/index.ts ===
import * as foo from "foo";
>foo : Symbol(foo, Decl(index.ts, 0, 6))
class Test {
>Test : Symbol(Test, Decl(index.ts, 0, 27))
bar: foo.Foo;
>bar : Symbol(bar, Decl(index.ts, 2, 12))
>foo : Symbol(foo, Decl(index.ts, 0, 6))
>Foo : Symbol(foo.Foo, Decl(foo.d.ts, 1, 22), Decl(foo-ext.d.ts, 0, 22))
constructor() {
this.bar = new foo.Foo();
>this.bar : Symbol(bar, Decl(index.ts, 2, 12))
>this : Symbol(Test, Decl(index.ts, 0, 27))
>bar : Symbol(bar, Decl(index.ts, 2, 12))
>foo.Foo : Symbol(foo.Foo, Decl(foo.d.ts, 1, 22), Decl(foo-ext.d.ts, 0, 22))
>foo : Symbol(foo, Decl(index.ts, 0, 6))
>Foo : Symbol(foo.Foo, Decl(foo.d.ts, 1, 22), Decl(foo-ext.d.ts, 0, 22))
}
}

View File

@@ -0,0 +1,47 @@
=== tests/cases/compiler/foo.d.ts ===
declare module "foo" {
export class Foo {
>Foo : Foo
constructor();
method1(): any;
>method1 : () => any
}
}
=== tests/cases/compiler/foo-ext.d.ts ===
declare module "foo" {
export interface Foo {
>Foo : Foo
method2(): any;
>method2 : () => any
}
}
=== tests/cases/compiler/index.ts ===
import * as foo from "foo";
>foo : typeof foo
class Test {
>Test : Test
bar: foo.Foo;
>bar : foo.Foo
>foo : any
>Foo : foo.Foo
constructor() {
this.bar = new foo.Foo();
>this.bar = new foo.Foo() : foo.Foo
>this.bar : foo.Foo
>this : this
>bar : foo.Foo
>new foo.Foo() : foo.Foo
>foo.Foo : typeof foo.Foo
>foo : typeof foo
>Foo : typeof foo.Foo
}
}

View File

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

View File

@@ -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 = {}));

View File

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

View File

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