diff --git a/tests/baselines/reference/classAbstractCrashedOnce.errors.txt b/tests/baselines/reference/classAbstractCrashedOnce.errors.txt new file mode 100644 index 00000000000..c2e38a6cf44 --- /dev/null +++ b/tests/baselines/reference/classAbstractCrashedOnce.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts(8,5): error TS1003: Identifier expected. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts (1 errors) ==== + abstract class foo { + protected abstract test(); + } + + class bar extends foo { + test() { + this. + } + ~ +!!! error TS1003: Identifier expected. + } + var x = new bar(); \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractCrashedOnce.js b/tests/baselines/reference/classAbstractCrashedOnce.js new file mode 100644 index 00000000000..f4268a4a13c --- /dev/null +++ b/tests/baselines/reference/classAbstractCrashedOnce.js @@ -0,0 +1,35 @@ +//// [classAbstractCrashedOnce.ts] +abstract class foo { + protected abstract test(); +} + +class bar extends foo { + test() { + this. + } +} +var x = new bar(); + +//// [classAbstractCrashedOnce.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() { + } + return foo; +})(); +var bar = (function (_super) { + __extends(bar, _super); + function bar() { + _super.apply(this, arguments); + } + bar.prototype.test = function () { + this. + ; + }; + return bar; +})(foo); +var x = new bar(); diff --git a/tests/baselines/reference/classAbstractImportInstantiation.errors.txt b/tests/baselines/reference/classAbstractImportInstantiation.errors.txt new file mode 100644 index 00000000000..76110afa4ff --- /dev/null +++ b/tests/baselines/reference/classAbstractImportInstantiation.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts(4,5): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts(9,1): error TS2511: Cannot create an instance of the abstract class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts (2 errors) ==== + module M { + export abstract class A {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + } + + import myA = M.A; + + new myA; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractImportInstantiation.js b/tests/baselines/reference/classAbstractImportInstantiation.js new file mode 100644 index 00000000000..bb25181f20d --- /dev/null +++ b/tests/baselines/reference/classAbstractImportInstantiation.js @@ -0,0 +1,25 @@ +//// [classAbstractImportInstantiation.ts] +module M { + export abstract class A {} + + new A; +} + +import myA = M.A; + +new myA; + + +//// [classAbstractImportInstantiation.js] +var M; +(function (M) { + var A = (function () { + function A() { + } + return A; + })(); + M.A = A; + new A; +})(M || (M = {})); +var myA = M.A; +new myA; diff --git a/tests/baselines/reference/classAbstractInstantiations1.errors.txt b/tests/baselines/reference/classAbstractInstantiations1.errors.txt new file mode 100644 index 00000000000..0221ce07f95 --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations1.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (2 errors) ==== + + abstract class A {} + + class B extends A {} + + abstract class C extends B {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new B; + new C; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. + + var a : A; + var b : B; + var c : C; + + a = new B; + b = new B; + c = new B; + \ No newline at end of file diff --git a/tests/baselines/reference/classInstantiatingAbstractClass.js b/tests/baselines/reference/classAbstractInstantiations1.js similarity index 68% rename from tests/baselines/reference/classInstantiatingAbstractClass.js rename to tests/baselines/reference/classAbstractInstantiations1.js index 6a2c3f31e37..39e67542926 100644 --- a/tests/baselines/reference/classInstantiatingAbstractClass.js +++ b/tests/baselines/reference/classAbstractInstantiations1.js @@ -1,4 +1,4 @@ -//// [classInstantiatingAbstractClass.ts] +//// [classAbstractInstantiations1.ts] abstract class A {} @@ -17,17 +17,9 @@ var c : C; a = new B; b = new B; c = new B; - -module M { - export abstract class A {} -} - -import myA = M.A; - -var aa = new myA; -//// [classInstantiatingAbstractClass.js] +//// [classAbstractInstantiations1.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; } @@ -61,14 +53,3 @@ var c; a = new B; b = new B; c = new B; -var M; -(function (M) { - var A = (function () { - function A() { - } - return A; - })(); - M.A = A; -})(M || (M = {})); -var myA = M.A; -var aa = new myA; diff --git a/tests/baselines/reference/classAbstractInstantiations2.errors.txt b/tests/baselines/reference/classAbstractInstantiations2.errors.txt new file mode 100644 index 00000000000..c3cb4a4cae4 --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations2.errors.txt @@ -0,0 +1,90 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(6,28): error TS2304: Cannot find name 'bar'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(17,5): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'B.bar'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(45,14): error TS2516: All declarations of an abstract method must be consecutive. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(45,20): error TS1144: '{' or ';' expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(45,20): error TS2300: Duplicate identifier 'boolean'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be `abstract` or not `abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,21): error TS1144: '{' or ';' expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,21): error TS2300: Duplicate identifier 'boolean'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(49,7): error TS2514: Classes containing abstract functions must be marked abstract. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (12 errors) ==== + class A { + // ... + } + + abstract class B { + foo(): number { return bar(); } + ~~~ +!!! error TS2304: Cannot find name 'bar'. + abstract bar() : number; + } + + new B; // error + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + + var BB: typeof B = B; + var AA: typeof A = BB; // error, AA is not of abstract type. + new AA; + + function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof C + ~~~~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + } + + var BB = B; + new BB; // error -- BB is of type typeof C + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + + var x : any = C; + new x; // okay -- undefined behavior at runtime + + class C extends B { } // error -- not declared abstract + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'B.bar'. + + abstract class D extends B { } // okay + + class E extends B { // okay -- implements abstract method + bar() { return 1; } + } + + abstract class F extends B { + abstract foo() : number; + bar() { return 2; } + } + + abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom() boolean; + ~~~ +!!! error TS2516: All declarations of an abstract method must be consecutive. + ~~~~~~~ +!!! error TS1144: '{' or ';' expected. + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'boolean'. + nom(x : number) boolean; // error -- use of modifier abstract must match on all overloads. + ~~~ +!!! error TS2512: Overload signatures must all be `abstract` or not `abstract. + ~~~~~~~ +!!! error TS1144: '{' or ';' expected. + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'boolean'. + } + + class H { // error -- not declared abstract + ~ +!!! error TS2514: Classes containing abstract functions must be marked abstract. + abstract baz() : number; + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInstantiations2.js b/tests/baselines/reference/classAbstractInstantiations2.js new file mode 100644 index 00000000000..055bdfedbc3 --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations2.js @@ -0,0 +1,123 @@ +//// [classAbstractInstantiations2.ts] +class A { + // ... +} + +abstract class B { + foo(): number { return bar(); } + abstract bar() : number; +} + +new B; // error + +var BB: typeof B = B; +var AA: typeof A = BB; // error, AA is not of abstract type. +new AA; + +function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof C +} + +var BB = B; +new BB; // error -- BB is of type typeof C + +var x : any = C; +new x; // okay -- undefined behavior at runtime + +class C extends B { } // error -- not declared abstract + +abstract class D extends B { } // okay + +class E extends B { // okay -- implements abstract method + bar() { return 1; } +} + +abstract class F extends B { + abstract foo() : number; + bar() { return 2; } +} + +abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom() boolean; + nom(x : number) boolean; // error -- use of modifier abstract must match on all overloads. +} + +class H { // error -- not declared abstract + abstract baz() : number; +} + +//// [classAbstractInstantiations2.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 A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + B.prototype.foo = function () { return bar(); }; + return B; +})(); +new B; // error +var BB = B; +var AA = BB; // error, AA is not of abstract type. +new AA; +function constructB(Factory) { + new Factory; // error -- Factory is of type typeof C +} +var BB = B; +new BB; // error -- BB is of type typeof C +var x = C; +new x; // okay -- undefined behavior at runtime +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B); // error -- not declared abstract +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(B); // okay +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.bar = function () { return 1; }; + return E; +})(B); +var F = (function (_super) { + __extends(F, _super); + function F() { + _super.apply(this, arguments); + } + F.prototype.bar = function () { return 2; }; + return F; +})(B); +var G = (function () { + function G() { + } + G.prototype.nom = ; + G.prototype.nom = ; + return G; +})(); +var H = (function () { + function H() { + } + return H; +})(); diff --git a/tests/baselines/reference/classAbstractManyKeywords.errors.txt b/tests/baselines/reference/classAbstractManyKeywords.errors.txt new file mode 100644 index 00000000000..b200404eaf0 --- /dev/null +++ b/tests/baselines/reference/classAbstractManyKeywords.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,25): error TS1005: ';' expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(3,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(4,17): error TS1005: '=' expected. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts (4 errors) ==== + export default abstract class A {} + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. + ~~~~~ +!!! error TS1005: ';' expected. + export abstract class B {} + default abstract class C {} + ~~~~~~~ +!!! error TS1128: Declaration or statement expected. + import abstract class D {} + ~~~~~ +!!! error TS1005: '=' expected. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractManyKeywords.js b/tests/baselines/reference/classAbstractManyKeywords.js new file mode 100644 index 00000000000..79191c029e1 --- /dev/null +++ b/tests/baselines/reference/classAbstractManyKeywords.js @@ -0,0 +1,28 @@ +//// [classAbstractManyKeywords.ts] +export default abstract class A {} +export abstract class B {} +default abstract class C {} +import abstract class D {} + +//// [classAbstractManyKeywords.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +exports.B = B; +var C = (function () { + function C() { + } + return C; +})(); +var D = (function () { + function D() { + } + return D; +})(); diff --git a/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt b/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt new file mode 100644 index 00000000000..5af440ed4df --- /dev/null +++ b/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(12,1): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts (3 errors) ==== + abstract class A {} + + abstract + class B {} + + abstract + + class C {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new B; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + new C; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMultiLineDecl.js b/tests/baselines/reference/classAbstractMultiLineDecl.js new file mode 100644 index 00000000000..3a92e2aa1e5 --- /dev/null +++ b/tests/baselines/reference/classAbstractMultiLineDecl.js @@ -0,0 +1,33 @@ +//// [classAbstractMultiLineDecl.ts] +abstract class A {} + +abstract +class B {} + +abstract + +class C {} + +new A; +new B; +new C; + +//// [classAbstractMultiLineDecl.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +var C = (function () { + function C() { + } + return C; +})(); +new A; +new B; +new C; diff --git a/tests/baselines/reference/classInstantiatingAbstractClass.errors.txt b/tests/baselines/reference/classInstantiatingAbstractClass.errors.txt deleted file mode 100644 index a9da2f38c37..00000000000 --- a/tests/baselines/reference/classInstantiatingAbstractClass.errors.txt +++ /dev/null @@ -1,39 +0,0 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'C'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts(26,10): error TS2511: Cannot create an instance of the abstract class 'A'. - - -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classInstantiatingAbstractClass.ts (3 errors) ==== - - abstract class A {} - - class B extends A {} - - abstract class C extends B {} - - new A; - ~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'A'. - new B; - new C; - ~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'C'. - - var a : A; - var b : B; - var c : C; - - a = new B; - b = new B; - c = new B; - - module M { - export abstract class A {} - } - - import myA = M.A; - - var aa = new myA; - ~~~~~~~ -!!! error TS2511: Cannot create an instance of the abstract class 'A'. - \ No newline at end of file