From 5ad2ced0c345141272ea101656d1b0ba45411884 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 8 May 2017 11:03:41 -0700 Subject: [PATCH] Update test with trickier case from #15616 --- ...aintOfJavascriptClassExpression.errors.txt | 42 +++++++++++++++++++ ...exConstraintOfJavascriptClassExpression.js | 32 -------------- ...exConstraintOfJavascriptClassExpression.ts | 8 ++++ 3 files changed, 50 insertions(+), 32 deletions(-) create mode 100644 tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.errors.txt delete mode 100644 tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.js diff --git a/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.errors.txt b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.errors.txt new file mode 100644 index 00000000000..f648f52bb58 --- /dev/null +++ b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.errors.txt @@ -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'? + } + } + }); + \ No newline at end of file diff --git a/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.js b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.js deleted file mode 100644 index a23461a1b58..00000000000 --- a/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.js +++ /dev/null @@ -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)); -}); diff --git a/tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts b/tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts index 8de18a69536..51af2b276a2 100644 --- a/tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts +++ b/tests/cases/compiler/checkIndexConstraintOfJavascriptClassExpression.ts @@ -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; + } } });