Update test with trickier case from #15616

This commit is contained in:
Nathan Shively-Sanders
2017-05-08 11:03:41 -07:00
parent 6038ea09c9
commit 5ad2ced0c3
3 changed files with 50 additions and 32 deletions

View File

@@ -0,0 +1,42 @@
tests/cases/compiler/weird.js(1,1): error TS2304: Cannot find name 'someFunction'.
tests/cases/compiler/weird.js(1,23): error TS7006: Parameter 'BaseClass' implicitly has an 'any' type.
tests/cases/compiler/weird.js(4,17): error TS8009: 'const' can only be used in a .ts file.
tests/cases/compiler/weird.js(4,17): error TS1248: A class member cannot have the 'const' keyword.
tests/cases/compiler/weird.js(5,3): error TS2377: Constructors for derived classes must contain a 'super' call.
tests/cases/compiler/weird.js(6,4): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/weird.js(8,25): error TS7006: Parameter 'error' implicitly has an 'any' type.
tests/cases/compiler/weird.js(9,54): error TS2663: Cannot find name 'DEFAULT_MESSAGE'. Did you mean the instance member 'this.DEFAULT_MESSAGE'?
==== tests/cases/compiler/weird.js (8 errors) ====
someFunction(function(BaseClass) {
~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'someFunction'.
~~~~~~~~~
!!! error TS7006: Parameter 'BaseClass' implicitly has an 'any' type.
'use strict';
class Hello extends BaseClass {
const DEFAULT_MESSAGE = "nop!";
~~~~~
!!! error TS8009: 'const' can only be used in a .ts file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1248: A class member cannot have the 'const' keyword.
constructor() {
~~~~~~~~~~~~~~~
this.foo = "bar";
~~~~~~~~~~~~~~~~~~~~
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
}
~~~
!!! error TS2377: Constructors for derived classes must contain a 'super' call.
_render(error) {
~~~~~
!!! error TS7006: Parameter 'error' implicitly has an 'any' type.
const message = error.message || DEFAULT_MESSAGE;
~~~~~~~~~~~~~~~
!!! error TS2663: Cannot find name 'DEFAULT_MESSAGE'. Did you mean the instance member 'this.DEFAULT_MESSAGE'?
}
}
});

View File

@@ -1,32 +0,0 @@
//// [weird.js]
someFunction(function(BaseClass) {
class Hello extends BaseClass {
constructor() {
this.foo = "bar";
}
}
});
//// [foo.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
someFunction(function (BaseClass) {
var Hello = (function (_super) {
__extends(Hello, _super);
function Hello() {
var _this = this;
_this.foo = "bar";
return _this;
}
return Hello;
}(BaseClass));
});

View File

@@ -1,10 +1,18 @@
// @Filename: weird.js
// @allowJs: true
// @checkJs: true
// @strict: true
// @noEmit: true
// @out: foo.js
someFunction(function(BaseClass) {
'use strict';
class Hello extends BaseClass {
const DEFAULT_MESSAGE = "nop!";
constructor() {
this.foo = "bar";
}
_render(error) {
const message = error.message || DEFAULT_MESSAGE;
}
}
});