Skip to content
Merged
Prev Previous commit
Next Next commit
Fixed tests after changing the default of useDefineForClassFields to …
…true for target esnext
  • Loading branch information
dragomirtitian committed Apr 5, 2021
commit ce875d46b79dd20faa1fa9dcb06be4e75b4ae850
1 change: 1 addition & 0 deletions src/testRunner/unittests/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ namespace ts {
compilerOptions: {
target: ScriptTarget.ESNext,
newLine: NewLineKind.CarriageReturnLineFeed,
useDefineForClassFields: false,
}
}).outputText;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

//// [classWithStaticFieldInParameterBindingPattern.js]
// https://github.com/microsoft/TypeScript/issues/36295
((_a) => { var _b; var { [(_b = class {
},
_b.x = 1,
_b).x]: b = "" } = _a; })();
(({ [class {
static x = 1;
}.x]: b = "" }) => { })();
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

//// [classWithStaticFieldInParameterInitializer.js]
// https://github.com/microsoft/TypeScript/issues/36295
((b) => { var _a; if (b === void 0) { b = (_a = class {
},
_a.x = 1,
_a); } })();
((b = class {
static x = 1;
}) => { })();
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ class A {

//// [privateNameAndStaticInitializer.js]
class A {
constructor() {
this.#foo = 1;
this.#prop = 2;
}
#foo;
#prop;
#foo = 1;
static inst = new A();
#prop = 2;
}
A.inst = new A();
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,15 @@ new A().test();

//// [privateNameComputedPropertyName1.js]
class A {
#a = 'a';
#b;
#c = 'c';
#d;
#e = '';
constructor() {
this.#a = 'a';
this.#c = 'c';
this.#e = '';
this.#b = 'b';
this.#d = 'd';
}
#a;
#b;
#c;
#d;
#e;
test() {
const data = { a: 'a', b: 'b', c: 'c', d: 'd', e: 'e' };
const { [this.#a]: a, [this.#b]: b, [this.#c]: c, [this.#d]: d, [this.#e = 'e']: e, } = data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ console.log(getX(new A));
//// [privateNameComputedPropertyName2.js]
let getX;
class A {
constructor() {
this.#x = 100;
}
#x;
#x = 100;
[(getX = (a) => a.#x, "_")]() { }
}
console.log(getX(new A));
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@ console.log(new Foo("NAME").getValue(100));

//// [privateNameComputedPropertyName3.js]
class Foo {
#name;
constructor(name) {
this.#name = name;
}
#name;
getValue(x) {
const obj = this;
class Bar {
constructor() {
this.#y = 100;
}
#y;
#y = 100;
[obj.#name]() {
return x + this.#y;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ class A {

//// [privateNameFieldDestructuredBinding.js]
class A {
#field = 1;
otherObject = new A();
testObject() {
return { x: 10, y: 6 };
}
testArray() {
return [10, 11];
}
constructor() {
this.#field = 1;
this.otherObject = new A();
let y;
({ x: this.#field, y } = this.testObject());
([this.#field, y] = this.testArray());
Expand All @@ -38,13 +44,6 @@ class A {
[this.#field = 2] = [];
[this.otherObject.#field = 2] = [];
}
#field;
testObject() {
return { x: 10, y: 6 };
}
testArray() {
return [10, 11];
}
static test(_a) {
[_a.#field] = [2];
}
Expand Down
1 change: 1 addition & 0 deletions tests/cases/compiler/awaitInClassInAsyncFunction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @target: esnext
// @useDefineForClassFields: false
// https://github.com/microsoft/TypeScript/issues/34887

async function bar() {
Expand Down
1 change: 1 addition & 0 deletions tests/cases/compiler/checkSuperCallBeforeThisAccess.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @strict: true
// @target: esnext
// @useDefineForClassFields: false

class A {
x = 1;
Expand Down
1 change: 1 addition & 0 deletions tests/cases/compiler/classIndexer5.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @target: esnext
// @useDefineForClassFields: false

class Foo {
[key: string]: number;
Expand Down
1 change: 1 addition & 0 deletions tests/cases/compiler/controlFlowPrivateClassField.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @strict: true
// @target: esnext
// @useDefineForClassFields: false
class Example {
#test;

Expand Down
1 change: 1 addition & 0 deletions tests/cases/compiler/customAsyncIterator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @target: esnext
// @useDefineForClassFields: false

// GH: https://github.com/microsoft/TypeScript/issues/33239
class ConstantIterator<T> implements AsyncIterator<T, undefined, T | undefined> {
Expand Down
2 changes: 2 additions & 0 deletions tests/cases/compiler/dynamicNamesErrors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @target: esnext
// @module: commonjs
// @declaration: true
// @useDefineForClassFields: false

const c0 = "1";
const c1 = 1;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @strict: true
// @target: esnext
// @useDefineForClassFields: false

class A { private x: unknown; y?: string; }
class B { private x: unknown; y?: string; }
Expand Down
1 change: 1 addition & 0 deletions tests/cases/compiler/potentiallyUncalledDecorators.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @target: esnext
// @module: esnext
// @experimentalDecorators: true
// @useDefineForClassFields: false

// Angular-style Input/Output API:
declare function Input(bindingPropertyName?: string): any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @target: esnext
// @useDefineForClassFields: false

class C {
a = 123;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @target: esnext
// @lib: esnext
// @useDefineForClassFields: false

class A {
#foo(a: number) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @strict: true
// @target: esnext
// @lib: esnext
// @useDefineForClassFields: false

class A {
static #foo(a: number) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @strict: true
// @target: esnext
// @useDefineForClassFields: false

class Foo {
#p1: (v: any) => asserts v is string = (v) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @target: esnext
// @useDefineForClassFields: false
interface Mup<K, V> {
readonly size: number;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @module: amd
// @target: esnext
// @useDefineForClassFields: false

// @filename: 0.ts
export class B {
print() { return "I am B"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @module: commonjs
// @target: esnext
// @useDefineForClassFields: false

// @filename: 0.ts
export class B {
print() { return "I am B"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @module: system
// @target: esnext
// @useDefineForClassFields: false

// @filename: 0.ts
export class B {
print() { return "I am B"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @module: umd
// @target: esnext
// @useDefineForClassFields: false
// @filename: 0.ts
export class B {
print() { return "I am B"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @target: esnext
// @strict: true
// @useDefineForClassFields: false

export interface SomethingTaggable {
<T>(t: TemplateStringsArray, ...args: T[]): SomethingNewable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @strict: true
// @target: esnext
// @useDefineForClassFields: false

class A {
a?: A
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @target: esnext
// @useDefineForClassFields: false
class MyTestClass {
private canary: number;
static staticCanary: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @target: esnext
// @useDefineForClassFields: false

// @Filename: framework-hooks.ts
export const onInit = Symbol("onInit");
Expand Down
1 change: 1 addition & 0 deletions tests/cases/conformance/jsdoc/jsdocReadonlyDeclarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// @out: foo.js
// @declaration: true
// @Filename: jsdocReadonlyDeclarations.js
// @useDefineForClassFields: false
class C {
/** @readonly */
x = 6
Expand Down
1 change: 1 addition & 0 deletions tests/cases/conformance/types/spread/spreadMethods.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @target: esnext
// @useDefineForClassFields: false

class K {
p = 12;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @target: esnext
// @lib: esnext
// @declaration: false
// @useDefineForClassFields: false

// declarations with call initializer
const constCall = Symbol();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @target: esnext
// @lib: esnext
// @declaration: true
// @useDefineForClassFields: false

// declarations with call initializer
const constCall = Symbol();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// @lib: esnext
// @module: commonjs
// @declaration: true
// @useDefineForClassFields: false

declare const s: unique symbol;
interface I { readonly readonlyType: unique symbol; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// @checkJs: true
// @filename: uniqueSymbolsDeclarationsInJs.js
// @out: uniqueSymbolsDeclarationsInJs-out.js
// @useDefineForClassFields: false

// classes
class C {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// @checkJs: true
// @filename: uniqueSymbolsDeclarationsInJsErrors.js
// @out: uniqueSymbolsDeclarationsInJsErrors-out.js
// @useDefineForClassFields: false

class C {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @target: esnext
// @useDefineForClassFields: false

// declarations
declare const invalidUniqueType: unique number;
Expand Down