file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
crates/swc_ecma_parser/tests/tsc/privateNameComputedPropertyName1.ts
TypeScript
// @target: esnext, es2022, es2015 class A { #a = 'a'; #b: string; readonly #c = 'c'; readonly #d: string; #e = ''; constructor() { this.#b = 'b'; this.#d = 'd'; } test() { const data: Record<string, string> = { 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; console.log(a, b, c, d, e); const a1 = data[this.#a]; const b1 = data[this.#b]; const c1 = data[this.#c]; const d1 = data[this.#d]; const e1 = data[this.#e]; console.log(a1, b1, c1, d1); } } new A().test();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameComputedPropertyName2.ts
TypeScript
// @target: esnext, es2022, es2015 let getX: (a: A) => number; class A { #x = 100; [(getX = (a: A) => a.#x, "_")]() {} } console.log(getX(new A));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameComputedPropertyName3.ts
TypeScript
// @target: esnext, es2022, es2015 class Foo { #name; constructor(name) { this.#name = name; } getValue(x) { const obj = this; class Bar { #y = 100; [obj.#name]() { return x + this.#y; } } return new Bar()[obj.#name](); } } console.log(new Foo("NAME").getValue(100));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameComputedPropertyName4.ts
TypeScript
// @target: esnext, es2022, es2015 // @useDefineForClassFields: true // @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/44113 class C1 { static #qux = 42; ["bar"] () {} } class C2 { static #qux = 42; static ["bar"] () {} } class C3 { static #qux = 42; static ["bar"] = "test"; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameConstructorSignature.ts
TypeScript
// @target: es2015 interface D { x: number; } class C { #x; static test() { new C().#x = 10; const y = new C(); const z = new y(); z.x = 123; } } interface C { new (): D; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameDeclaration.ts
TypeScript
// @declaration: true // @target: es2015 class A { #foo: string; #bar = 6; baz: string; qux = 6; quux(): void { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameDeclarationMerging.ts
TypeScript
// @target: es6 class D {}; class C { #x; foo () { const c = new C(); c.#x; // OK const d: D = new C(); d.#x; // Error } } interface C { new (): D; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameDuplicateField.ts
TypeScript
// @strict: true // @target: es6 function Field() { // Error class A_Field_Field { #foo = "foo"; #foo = "foo"; } // Error class A_Field_Method { #foo = "foo"; #foo() { } } // Error class A_Field_Getter { #foo = "foo"; get #foo() { return ""} } // Error class A_Field_Setter { #foo = "foo"; set #foo(value: string) { } } // Error class A_Field_StaticField { #foo = "foo"; static #foo = "foo"; } // Error class A_Field_StaticMethod { #foo = "foo"; static #foo() { } } // Error class A_Field_StaticGetter { #foo = "foo"; static get #foo() { return ""} } // Error class A_Field_StaticSetter { #foo = "foo"; static set #foo(value: string) { } } } function Method() { // Error class A_Method_Field { #foo() { } #foo = "foo"; } // Error class A_Method_Method { #foo() { } #foo() { } } // Error class A_Method_Getter { #foo() { } get #foo() { return ""} } // Error class A_Method_Setter { #foo() { } set #foo(value: string) { } } // Error class A_Method_StaticField { #foo() { } static #foo = "foo"; } // Error class A_Method_StaticMethod { #foo() { } static #foo() { } } // Error class A_Method_StaticGetter { #foo() { } static get #foo() { return ""} } // Error class A_Method_StaticSetter { #foo() { } static set #foo(value: string) { } } } function Getter() { // Error class A_Getter_Field { get #foo() { return ""} #foo = "foo"; } // Error class A_Getter_Method { get #foo() { return ""} #foo() { } } // Error class A_Getter_Getter { get #foo() { return ""} get #foo() { return ""} } //OK class A_Getter_Setter { get #foo() { return ""} set #foo(value: string) { } } // Error class A_Getter_StaticField { get #foo() { return ""} static #foo() { } } // Error class A_Getter_StaticMethod { get #foo() { return ""} static #foo() { } } // Error class A_Getter_StaticGetter { get #foo() { return ""} static get #foo() { return ""} } // Error class A_Getter_StaticSetter { get #foo() { return ""} static set #foo(value: string) { } } } function Setter() { // Error class A_Setter_Field { set #foo(value: string) { } #foo = "foo"; } // Error class A_Setter_Method { set #foo(value: string) { } #foo() { } } // OK class A_Setter_Getter { set #foo(value: string) { } get #foo() { return ""} } // Error class A_Setter_Setter { set #foo(value: string) { } set #foo(value: string) { } } // Error class A_Setter_StaticField { set #foo(value: string) { } static #foo = "foo"; } // Error class A_Setter_StaticMethod { set #foo(value: string) { } static #foo() { } } // Error class A_Setter_StaticGetter { set #foo(value: string) { } static get #foo() { return ""} } // Error class A_Setter_StaticSetter { set #foo(value: string) { } static set #foo(value: string) { } } } function StaticField() { // Error class A_StaticField_Field { static #foo = "foo"; #foo = "foo"; } // Error class A_StaticField_Method { static #foo = "foo"; #foo() { } } // Error class A_StaticField_Getter { static #foo = "foo"; get #foo() { return ""} } // Error class A_StaticField_Setter { static #foo = "foo"; set #foo(value: string) { } } // Error class A_StaticField_StaticField { static #foo = "foo"; static #foo = "foo"; } // Error class A_StaticField_StaticMethod { static #foo = "foo"; static #foo() { } } // Error class A_StaticField_StaticGetter { static #foo = "foo"; static get #foo() { return ""} } // Error class A_StaticField_StaticSetter { static #foo = "foo"; static set #foo(value: string) { } } } function StaticMethod() { // Error class A_StaticMethod_Field { static #foo() { } #foo = "foo"; } // Error class A_StaticMethod_Method { static #foo() { } #foo() { } } // Error class A_StaticMethod_Getter { static #foo() { } get #foo() { return ""} } // Error class A_StaticMethod_Setter { static #foo() { } set #foo(value: string) { } } // Error class A_StaticMethod_StaticField { static #foo() { } static #foo = "foo"; } // Error class A_StaticMethod_StaticMethod { static #foo() { } static #foo() { } } // Error class A_StaticMethod_StaticGetter { static #foo() { } static get #foo() { return ""} } // Error class A_StaticMethod_StaticSetter { static #foo() { } static set #foo(value: string) { } } } function StaticGetter() { // Error class A_StaticGetter_Field { static get #foo() { return ""} #foo = "foo"; } // Error class A_StaticGetter_Method { static get #foo() { return ""} #foo() { } } // Error class A_StaticGetter_Getter { static get #foo() { return ""} get #foo() { return ""} } // Error class A_StaticGetter_Setter { static get #foo() { return ""} set #foo(value: string) { } } // Error class A_StaticGetter_StaticField { static get #foo() { return ""} static #foo() { } } // Error class A_StaticGetter_StaticMethod { static get #foo() { return ""} static #foo() { } } // Error class A_StaticGetter_StaticGetter { static get #foo() { return ""} static get #foo() { return ""} } // OK class A_StaticGetter_StaticSetter { static get #foo() { return ""} static set #foo(value: string) { } } } function StaticSetter() { // Error class A_StaticSetter_Field { static set #foo(value: string) { } #foo = "foo"; } // Error class A_StaticSetter_Method { static set #foo(value: string) { } #foo() { } } // Error class A_StaticSetter_Getter { static set #foo(value: string) { } get #foo() { return ""} } // Error class A_StaticSetter_Setter { static set #foo(value: string) { } set #foo(value: string) { } } // Error class A_StaticSetter_StaticField { static set #foo(value: string) { } static #foo = "foo"; } // Error class A_StaticSetter_StaticMethod { static set #foo(value: string) { } static #foo() { } } // OK class A_StaticSetter_StaticGetter { static set #foo(value: string) { } static get #foo() { return ""} } // Error class A_StaticSetter_StaticSetter { static set #foo(value: string) { } static set #foo(value: string) { } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameES5Ban.ts
TypeScript
// @target: es5 class A { constructor() {} #field = 123; #method() {} static #sField = "hello world"; static #sMethod() {} get #acc() { return ""; } set #acc(x: string) {} static get #sAcc() { return 0; } static set #sAcc(x: number) {} }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameEmitHelpers.ts
TypeScript
// @target: es2015 // @importHelpers: true // @isolatedModules: true // @filename: main.ts export class C { #a = 1; #b() { this.#c = 42; } set #c(v: number) { this.#a += v; } } // @filename: tslib.d.ts // these are pre-TS4.3 versions of emit helpers, which only supported private instance fields export declare function __classPrivateFieldGet<T extends object, V>(receiver: T, state: any): V; export declare function __classPrivateFieldSet<T extends object, V>(receiver: T, state: any, value: V): V;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameField.ts
TypeScript
// @strict: true // @target: es6 class A { #name: string; constructor(name: string) { this.#name = name; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameFieldAccess.ts
TypeScript
// @target: es2015 class A { #myField = "hello world"; constructor() { console.log(this.#myField); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameFieldAssignment.ts
TypeScript
// @target: es2015 class A { #field = 0; constructor() { this.#field = 1; this.#field += 2; this.#field -= 3; this.#field /= 4; this.#field *= 5; this.#field **= 6; this.#field %= 7; this.#field <<= 8; this.#field >>= 9; this.#field >>>= 10; this.#field &= 11; this.#field |= 12; this.#field ^= 13; A.getInstance().#field = 1; A.getInstance().#field += 2; A.getInstance().#field -= 3; A.getInstance().#field /= 4; A.getInstance().#field *= 5; A.getInstance().#field **= 6; A.getInstance().#field %= 7; A.getInstance().#field <<= 8; A.getInstance().#field >>= 9; A.getInstance().#field >>>= 10; A.getInstance().#field &= 11; A.getInstance().#field |= 12; A.getInstance().#field ^= 13; } static getInstance() { return new A(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameFieldCallExpression.ts
TypeScript
// @target: es2015 class A { #fieldFunc = function() { this.x = 10; }; #fieldFunc2 = function(a, ...b) {}; x = 1; test() { this.#fieldFunc(); this.#fieldFunc?.(); const func = this.#fieldFunc; func(); new this.#fieldFunc(); const arr = [ 1, 2 ]; this.#fieldFunc2(0, ...arr, 3); const b = new this.#fieldFunc2(0, ...arr, 3); const str = this.#fieldFunc2`head${1}middle${2}tail`; this.getInstance().#fieldFunc2`test${1}and${2}`; } getInstance() { return new A(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameFieldClassExpression.ts
TypeScript
// @target: es2015 class B { #foo = class { constructor() { console.log("hello"); } static test = 123; }; #foo2 = class Foo { static otherClass = 123; }; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameFieldDestructuredBinding.ts
TypeScript
// @target: esnext, es2022, es2015 class A { #field = 1; otherObject = new A(); testObject() { return { x: 10, y: 6 }; } testArray() { return [10, 11]; } constructor() { let y: number; ({ x: this.#field, y } = this.testObject()); ([this.#field, y] = this.testArray()); ({ a: this.#field, b: [this.#field] } = { a: 1, b: [2] }); [this.#field, [this.#field]] = [1, [2]]; ({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }); [this.#field = 2] = []; [this.otherObject.#field = 2] = []; } static test(_a: A) { [_a.#field] = [2]; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameFieldInitializer.ts
TypeScript
// @target: es2015 class A { #field = 10; #uninitialized; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameFieldParenthesisLeftAssignment.ts
TypeScript
// @target: es2015 class Foo { #p: number; constructor(value: number) { this.#p = value; } t1(p: number) { (this.#p as number) = p; } t2(p: number) { (((this.#p as number))) = p; } t3(p: number) { (this.#p) = p; } t4(p: number) { (((this.#p))) = p; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameFieldUnaryMutation.ts
TypeScript
// @target: es2015 class C { #test: number = 24; constructor() { this.#test++; this.#test--; ++this.#test; --this.#test; const a = this.#test++; const b = this.#test--; const c = ++this.#test; const d = --this.#test; for (this.#test = 0; this.#test < 10; ++this.#test) {} for (this.#test = 0; this.#test < 10; this.#test++) {} (this.#test)++; (this.#test)--; ++(this.#test); --(this.#test); const e = (this.#test)++; const f = (this.#test)--; const g = ++(this.#test); const h = --(this.#test); for (this.#test = 0; this.#test < 10; ++(this.#test)) {} for (this.#test = 0; this.#test < 10; (this.#test)++) {} } test() { this.getInstance().#test++; this.getInstance().#test--; ++this.getInstance().#test; --this.getInstance().#test; const a = this.getInstance().#test++; const b = this.getInstance().#test--; const c = ++this.getInstance().#test; const d = --this.getInstance().#test; for (this.getInstance().#test = 0; this.getInstance().#test < 10; ++this.getInstance().#test) {} for (this.getInstance().#test = 0; this.getInstance().#test < 10; this.getInstance().#test++) {} (this.getInstance().#test)++; (this.getInstance().#test)--; ++(this.getInstance().#test); --(this.getInstance().#test); const e = (this.getInstance().#test)++; const f = (this.getInstance().#test)--; const g = ++(this.getInstance().#test); const h = --(this.getInstance().#test); for (this.getInstance().#test = 0; this.getInstance().#test < 10; ++(this.getInstance().#test)) {} for (this.getInstance().#test = 0; this.getInstance().#test < 10; (this.getInstance().#test)++) {} } getInstance() { return new C(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameFieldsESNext.ts
TypeScript
// @target: esnext, es2022 // @useDefineForClassFields: false class C { a = 123; #a = 10; c = "hello"; #b; method() { console.log(this.#a); this.#a = "hello"; console.log(this.#b); } static #m = "test"; static #x; static test() { console.log(this.#m); console.log(this.#x = "test"); } #something = () => 1234; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameImplicitDeclaration.ts
TypeScript
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: privateNameImplicitDeclaration.js class C { constructor() { /** @type {string} */ this.#x; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameInInExpressionUnused.ts
TypeScript
// @strict: true // @noUnusedLocals: true // @target: esnext, es2022 class Foo { #unused: undefined; // expect unused error #brand: undefined; // expect no error isFoo(v: any): v is Foo { // This should count as using/reading '#brand' return #brand in v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameInLhsReceiverExpression.ts
TypeScript
// @target: es2015 class Test { #y = 123; static something(obj: { [key: string]: Test }) { obj[(new class { #x = 1; readonly s = "prop"; }).s].#y = 1; obj[(new class { #x = 1; readonly s = "prop"; }).s].#y += 1; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameLateSuper.ts
TypeScript
// @target: es2015 class B {} class A extends B { #x; constructor() { void 0; super(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameLateSuperUseDefineForClassFields.ts
TypeScript
// @target: esnext, es2022 // @useDefineForClassFields: true class B {} class A extends B { #x; constructor() { void 0; super(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameMethod.ts
TypeScript
// @strict: true // @target: es6 class A1 { #method(param: string): string { return ""; } constructor(name: string) { this.#method("") this.#method(1) // Error this.#method() // Error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameMethodAssignment.ts
TypeScript
// @target: es2015 class A3 { #method() { }; constructor(a: A3, b: any) { this.#method = () => {} // Error, not writable a.#method = () => { }; // Error, not writable b.#method = () => { } //Error, not writable ({ x: this.#method } = { x: () => {}}); //Error, not writable let x = this.#method; b.#method++ //Error, not writable } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameMethodAsync.ts
TypeScript
// @target: es2019 const C = class { async #bar() { return await Promise.resolve(42); } async foo() { const b = await this.#bar(); return b + (this.#baz().next().value || 0) + ((await this.#qux().next()).value || 0); } *#baz() { yield 42; } async *#qux() { yield (await Promise.resolve(42)); } } new C().foo().then(console.log);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameMethodCallExpression.ts
TypeScript
// @target: es2015 class AA { #method() { this.x = 10; }; #method2(a, ...b) {}; x = 1; test() { this.#method(); const func = this.#method; func(); new this.#method(); const arr = [ 1, 2 ]; this.#method2(0, ...arr, 3); const b = new this.#method2(0, ...arr, 3); //Error const str = this.#method2`head${1}middle${2}tail`; this.getInstance().#method2`test${1}and${2}`; this.getInstance().#method2(0, ...arr, 3); const b2 = new (this.getInstance().#method2)(0, ...arr, 3); //Error const str2 = this.getInstance().#method2`head${1}middle${2}tail`; } getInstance() { return new AA(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameMethodInStaticFieldInit.ts
TypeScript
// @target: es2015 class C { static s = new C().#method(); #method() { return 42; } } console.log(C.s);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameNestedClassNameConflict.ts
TypeScript
// @target: es2015 class A { #foo: string; constructor() { class A { #foo: string; } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameReadonly.ts
TypeScript
// @target: es2015 const C = class { #bar() {} foo() { this.#bar = console.log("should log this then throw"); } } console.log(new C().foo());
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameSetterExprReturnValue.ts
TypeScript
// @target: es2019 class C { set #foo(a: number) {} bar() { let x = (this.#foo = 42 * 2); console.log(x); // 84 } } new C().bar();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameSetterNoGetter.ts
TypeScript
// @target: es2015 const C = class { set #x(x) {} m() { this.#x += 2; // Error } } console.log(new C().m());
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticAccessors.ts
TypeScript
// @strict: true // @target: es6 class A1 { static get #prop() { return ""; } static set #prop(param: string) { } static get #roProp() { return ""; } constructor(name: string) { A1.#prop = ""; A1.#roProp = ""; // Error console.log(A1.#prop); console.log(A1.#roProp); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticAccessorsCallExpression.ts
TypeScript
// @target: es2015 class A { static get #fieldFunc() { return function() { A.#x = 10; } } static get #fieldFunc2() { return function(a, ...b) {}; } static #x = 1; static test() { this.#fieldFunc(); const func = this.#fieldFunc; func(); new this.#fieldFunc(); const arr = [ 1, 2 ]; this.#fieldFunc2(0, ...arr, 3); const b = new this.#fieldFunc2(0, ...arr, 3); const str = this.#fieldFunc2`head${1}middle${2}tail`; this.getClass().#fieldFunc2`test${1}and${2}`; } static getClass() { return A; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticAccessorssDerivedClasses.ts
TypeScript
// @target: es2015 class Base { static get #prop(): number { return 123; } static method(x: typeof Derived) { console.log(x.#prop); } } class Derived extends Base { static method(x: typeof Derived) { console.log(x.#prop); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticAndStaticInitializer.ts
TypeScript
// @target: esnext, es2022, es2015 // @useDefineForClassFields: false class A { static #foo = 1; static #prop = 2; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticEmitHelpers.ts
TypeScript
// @target: es2015 // @importHelpers: true // @isolatedModules: true // @filename: main.ts export class S { static #a = 1; static #b() { this.#a = 42; } static get #c() { return S.#b(); } } // @filename: tslib.d.ts // these are pre-TS4.3 versions of emit helpers, which only supported private instance fields export declare function __classPrivateFieldGet<T extends object, V>(receiver: T, state: any): V; export declare function __classPrivateFieldSet<T extends object, V>(receiver: T, state: any, value: V): V;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticFieldAccess.ts
TypeScript
// @target: es2015 class A { static #myField = "hello world"; constructor() { console.log(A.#myField); //Ok console.log(this.#myField); //Error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticFieldAssignment.ts
TypeScript
// @target: es2015 class A { static #field = 0; constructor() { A.#field = 1; A.#field += 2; A.#field -= 3; A.#field /= 4; A.#field *= 5; A.#field **= 6; A.#field %= 7; A.#field <<= 8; A.#field >>= 9; A.#field >>>= 10; A.#field &= 11; A.#field |= 12; A.#field ^= 13; A.getClass().#field = 1; A.getClass().#field += 2; A.getClass().#field -= 3; A.getClass().#field /= 4; A.getClass().#field *= 5; A.getClass().#field **= 6; A.getClass().#field %= 7; A.getClass().#field <<= 8; A.getClass().#field >>= 9; A.getClass().#field >>>= 10; A.getClass().#field &= 11; A.getClass().#field |= 12; A.getClass().#field ^= 13; } static getClass() { return A; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticFieldCallExpression.ts
TypeScript
// @target: es2015 class A { static #fieldFunc = function () { this.x = 10; }; static #fieldFunc2 = function (a, ...b) {}; x = 1; test() { A.#fieldFunc(); A.#fieldFunc?.(); const func = A.#fieldFunc; func(); new A.#fieldFunc(); const arr = [ 1, 2 ]; A.#fieldFunc2(0, ...arr, 3); const b = new A.#fieldFunc2(0, ...arr, 3); const str = A.#fieldFunc2`head${1}middle${2}tail`; this.getClass().#fieldFunc2`test${1}and${2}`; } getClass() { return A; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticFieldClassExpression.ts
TypeScript
// @target: es2015 class B { static #foo = class { constructor() { console.log("hello"); new B.#foo2(); } static test = 123; field = 10; }; static #foo2 = class Foo { static otherClass = 123; }; m() { console.log(B.#foo.test) B.#foo.test = 10; new B.#foo().field; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticFieldDestructuredBinding.ts
TypeScript
// @target: esnext, es2022, es2015 // @useDefineForClassFields: false class A { static #field = 1; otherClass = A; testObject() { return { x: 10, y: 6 }; } testArray() { return [10, 11]; } constructor() { let y: number; ({ x: A.#field, y } = this.testObject()); ([A.#field, y] = this.testArray()); ({ a: A.#field, b: [A.#field] } = { a: 1, b: [2] }); [A.#field, [A.#field]] = [1, [2]]; ({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }); [A.#field = 2] = []; [this.otherClass.#field = 2] = []; } static test(_a: typeof A) { [_a.#field] = [2]; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticFieldInitializer.ts
TypeScript
// @target: es2015, es2022, esnext // @useDefineForClassFields: false class A { static #field = 10; static #uninitialized; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticFieldNoInitializer.ts
TypeScript
// @target: es2015, es2022, esnext const C = class { static #x; } class C2 { static #x; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticFieldUnaryMutation.ts
TypeScript
// @target: es2015 class C { static #test: number = 24; constructor() { C.#test++; C.#test--; ++C.#test; --C.#test; const a = C.#test++; const b = C.#test--; const c = ++C.#test; const d = --C.#test; for (C.#test = 0; C.#test < 10; ++C.#test) {} for (C.#test = 0; C.#test < 10; C.#test++) {} } test() { this.getClass().#test++; this.getClass().#test--; ++this.getClass().#test; --this.getClass().#test; const a = this.getClass().#test++; const b = this.getClass().#test--; const c = ++this.getClass().#test; const d = --this.getClass().#test; for (this.getClass().#test = 0; this.getClass().#test < 10; ++this.getClass().#test) {} for (this.getClass().#test = 0; this.getClass().#test < 10; this.getClass().#test++) {} } getClass() { return C; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticMethod.ts
TypeScript
// @strict: true // @target: es6 class A1 { static #method(param: string): string { return ""; } constructor() { A1.#method("") A1.#method(1) // Error A1.#method() // Error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticMethodAssignment.ts
TypeScript
// @target: es2015 class A3 { static #method() { }; constructor(a: typeof A3, b: any) { A3.#method = () => {} // Error, not writable a.#method = () => { }; // Error, not writable b.#method = () => { } //Error, not writable ({ x: A3.#method } = { x: () => {}}); //Error, not writable let x = A3.#method; b.#method++ //Error, not writable } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticMethodCallExpression.ts
TypeScript
// @target: es2015 class AA { static #method() { this.x = 10; }; static #method2(a, ...b) {}; static x = 1; test() { AA.#method(); const func = AA.#method; func(); new AA.#method(); const arr = [ 1, 2 ]; AA.#method2(0, ...arr, 3); const b = new AA.#method2(0, ...arr, 3); //Error const str = AA.#method2`head${1}middle${2}tail`; AA.getClass().#method2`test${1}and${2}`; AA.getClass().#method2(0, ...arr, 3); const b2 = new (AA.getClass().#method2)(0, ...arr, 3); //Error const str2 = AA.getClass().#method2`head${1}middle${2}tail`; } static getClass() { return AA; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticMethodInStaticFieldInit.ts
TypeScript
// @target: es2015 class C { static s = C.#method(); static #method() { return 42; } } console.log(C.s);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameStaticsAndStaticMethods.ts
TypeScript
// @strict: true // @target: esnext, es2022 // @lib: esnext, es2022 // @useDefineForClassFields: false class A { static #foo(a: number) {} static async #bar(a: number) {} static async *#baz(a: number) { return 3; } static #_quux: number; static get #quux (): number { return this.#_quux; } static set #quux (val: number) { this.#_quux = val; } constructor () { A.#foo(30); A.#bar(30); A.#bar(30); A.#quux = A.#quux + 1; A.#quux++; } } class B extends A { static #foo(a: string) {} constructor () { super(); B.#foo("str"); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameUnused.ts
TypeScript
// @noUnusedLocals:true // @noEmit: true // @target: es2015 export class A { #used = "used"; #unused = "unused"; constructor () { console.log(this.#used); } } export class A2 { #used() { }; #unused() { }; constructor () { console.log(this.#used()); } } export class A3 { get #used() { return 0 }; set #used(value: number) { }; get #unused() { return 0 }; set #unused(value: number) { }; constructor () { console.log(this.#used); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNameWhenNotUseDefineForClassFieldsInEsNext.ts
TypeScript
// @strict: true // @target: esNext,es2020 // @useDefineForClassFields: false class TestWithStatics { #prop = 0 static dd = new TestWithStatics().#prop; // OK static ["X_ z_ zz"] = class Inner { #foo = 10 m() { new TestWithStatics().#prop // OK } static C = class InnerInner { m() { new TestWithStatics().#prop // OK new Inner().#foo; // OK } } static M(){ return class { m() { new TestWithStatics().#prop // OK new Inner().#foo; // OK } } } } } class TestNonStatics { #prop = 0 dd = new TestNonStatics().#prop; // OK ["X_ z_ zz"] = class Inner { #foo = 10 m() { new TestNonStatics().#prop // Ok } C = class InnerInner { m() { new TestNonStatics().#prop // Ok new Inner().#foo; // Ok } } static M(){ return class { m() { new TestNonStatics().#prop // OK new Inner().#foo; // OK } } } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesAndFields.ts
TypeScript
// @strict: true // @target: es6 class A { #foo: number; constructor () { this.#foo = 3; } } class B extends A { #foo: string; constructor () { super(); this.#foo = "some string"; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesAndMethods.ts
TypeScript
// @target: esnext, es2022 // @lib: esnext, es2022 // @useDefineForClassFields: false class A { #foo(a: number) {} async #bar(a: number) {} async *#baz(a: number) { return 3; } #_quux: number; get #quux (): number { return this.#_quux; } set #quux (val: number) { this.#_quux = val; } constructor () { this.#foo(30); this.#bar(30); this.#baz(30); this.#quux = this.#quux + 1; this.#quux++; } } class B extends A { #foo(a: string) {} constructor () { super(); this.#foo("str"); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesAndStaticMethods.ts
TypeScript
// @strict: true // @target: esnext, es2022 // @lib: esnext, es2022 // @useDefineForClassFields: false class A { static #foo(a: number) {} static async #bar(a: number) {} static async *#baz(a: number) { return 3; } static #_quux: number; static get #quux (): number { return this.#_quux; } static set #quux (val: number) { this.#_quux = val; } constructor () { A.#foo(30); A.#bar(30); A.#bar(30); A.#quux = A.#quux + 1; A.#quux++; } } class B extends A { static #foo(a: string) {} constructor () { super(); B.#foo("str"); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesAndkeyof.ts
TypeScript
// @strict: true // @target: es6 class A { #fooField = 3; #fooMethod() { }; get #fooProp() { return 1; }; set #fooProp(value: number) { }; bar = 3; baz = 3; } // `keyof A` should not include '#foo*' let k: keyof A = "bar"; // OK k = "baz"; // OK k = "#fooField"; // Error k = "#fooMethod"; // Error k = "#fooProp"; // Error k = "fooField"; // Error k = "fooMethod"; // Error k = "fooProp"; // Error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesAssertion.ts
TypeScript
// @strict: true // @target: esnext, es2022 // @useDefineForClassFields: false class Foo { #p1: (v: any) => asserts v is string = (v) => { if (typeof v !== "string") { throw new Error(); } } m1(v: unknown) { this.#p1(v); v; } } class Foo2 { #p1(v: any): asserts v is string { if (typeof v !== "string") { throw new Error(); } } m1(v: unknown) { this.#p1(v); v; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesConstructorChain-1.ts
TypeScript
// @target: es2015 class Parent { #foo = 3; static #bar = 5; accessChildProps() { new Child().#foo; // OK (`#foo` was added when `Parent`'s constructor was called on `child`) Child.#bar; // Error: not found } } class Child extends Parent { #foo = "foo"; // OK (Child's #foo does not conflict, as `Parent`'s `#foo` is not accessible) #bar = "bar"; // OK }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesConstructorChain-2.ts
TypeScript
// @target: es2015 class Parent<T> { #foo = 3; static #bar = 5; accessChildProps() { new Child<string>().#foo; // OK (`#foo` was added when `Parent`'s constructor was called on `child`) Child.#bar; // Error: not found } } class Child<T> extends Parent<T> { #foo = "foo"; // OK (Child's #foo does not conflict, as `Parent`'s `#foo` is not accessible) #bar = "bar"; // OK } new Parent<number>().accessChildProps();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesIncompatibleModifiersJs.ts
TypeScript
// @allowJs: true // @checkJs: true // @strict: true // @target: es6 // @outDir: ./out // @filename: privateNamesIncompatibleModifiersJs.js class A { /** * @public */ #a = 1; /** * @private */ #b = 1; /** * @protected */ #c = 1; /** * @public */ #aMethod() { return 1; } /** * @private */ #bMethod() { return 1; } /** * @protected */ #cMethod() { return 1; } /** * @public */ get #aProp() { return 1; } /** * @public */ set #aProp(value) { } /** * @private */ get #bProp() { return 1; } /** * @private */ set #bProp(value) { } /** * @protected */ get #cProp() { return 1; } /** * @protected */ set #cProp(value) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesUnique-1.ts
TypeScript
// @strict: true // @target: es6 // @strictPropertyInitialization: false class A { #foo: number; } class B { #foo: number; } const b: A = new B(); // Error: Property #foo is missing
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesUnique-2.ts
TypeScript
// @target: es2015 // @filename: a.ts export class Foo { #x; copy(other: import("./b").Foo) { other.#x; // error } } // @filename: b.ts export class Foo { #x; } // @filename: main.ts import { Foo as A } from "./a"; import { Foo as B } from "./b"; const a = new A(); const b = new B(); a.copy(b); // error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesUnique-3.ts
TypeScript
// @target: es2015 class A { #foo = 1; static #foo = true; // error (duplicate) // because static and instance private names // share the same lexical scope // https://tc39.es/proposal-class-fields/#prod-ClassBody } class B { static #foo = true; test(x: B) { x.#foo; // error (#foo is a static property on B, not an instance property) } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesUnique-4.ts
TypeScript
// @target: es2015 class A1 { } interface A2 extends A1 { } declare const a: A2; class C { #something: number } const c: C = a;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesUnique-5.ts
TypeScript
// @strict: true // @target: es6 // @strictPropertyInitialization: false // same as privateNamesUnique-1, but with an interface class A { #foo: number; } interface A2 extends A { } class B { #foo: number; } const b: A2 = new B();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateNamesUseBeforeDef.ts
TypeScript
// @target: es2015 class A { #foo = this.#bar; // Error #bar = 3; } class A2 { #foo = this.#bar(); // No Error #bar() { return 3 }; } class A3 { #foo = this.#bar; // No Error get #bar() { return 3 }; } class B { #foo = this.#bar; // Error #bar = this.#foo; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateProtectedMembersAreNotAccessibleDestructuring.ts
TypeScript
class K { private priv; protected prot; private privateMethod() { } m() { let { priv: a, prot: b } = this; // ok let { priv, prot } = new K(); // ok } } class C extends K { m2() { let { priv: a } = this; // error let { prot: b } = this; // ok } } let k = new K(); let { priv } = k; // error let { prot } = k; // error let { privateMethod } = k; // error let { priv: a, prot: b, privateMethod: pm } = k; // error function f({ priv, prot, privateMethod }: K) { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateStaticMemberAccessibility.ts
TypeScript
class Base { private static foo: string; } class Derived extends Base { static bar = Base.foo; // error bing = () => Base.foo; // error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateStaticNameShadowing.ts
TypeScript
// @target: es2015 class X { static #f = X.#m(); constructor() { X.#m(); } static #m() { const X: any = {}; // shadow the class const _a: any = {}; // shadow the first generated var X.#m(); // Should check with X as the receiver with _b as the class constructor return 1; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateStaticNotAccessibleInClodule.ts
TypeScript
// Any attempt to access a private property member outside the class body that contains its declaration results in a compile-time error. class C { private foo: string; private static bar: string; } module C { export var y = C.bar; // error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateStaticNotAccessibleInClodule2.ts
TypeScript
// Any attempt to access a private property member outside the class body that contains its declaration results in a compile-time error. class C { private foo: string; private static bar: string; } class D extends C { baz: number; } module D { export var y = D.bar; // error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/privateWriteOnlyAccessorRead.ts
TypeScript
// @target: es2015 class Test { set #value(v: { foo: { bar: number } }) {} set #valueRest(v: number[]) {} set #valueOne(v: number) {} set #valueCompound(v: number) {} m() { const foo = { bar: 1 }; console.log(this.#value); // error this.#value = { foo }; // ok this.#value = { foo }; // ok this.#value.foo = foo; // error ({ o: this.#value } = { o: { foo } }); //ok ({ ...this.#value } = { foo }); //ok ({ foo: this.#value.foo } = { foo }); //error ({ foo: { ...this.#value.foo }, } = { foo }); //error let r = { o: this.#value }; //error [this.#valueOne, ...this.#valueRest] = [1, 2, 3]; let arr = [ this.#valueOne, ...this.#valueRest ]; this.#valueCompound += 3; } } new Test().m();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertiesOfGenericConstructorFunctions.ts
TypeScript
// @Filename: propertiesOfGenericConstructorFunctions.js // @allowJs: true // @checkJs: true // @noEmit: true /** * @template {string} K * @template V * @param {string} ik * @param {V} iv */ function Multimap(ik, iv) { /** @type {{ [s: string]: V }} */ this._map = {}; // without type annotation this._map2 = { [ik]: iv }; }; /** @type {Multimap<"a" | "b", number>} with type annotation */ const map = new Multimap("a", 1); // without type annotation const map2 = new Multimap("m", 2); /** @type {number} */ var n = map._map['hi'] /** @type {number} */ var n = map._map2['hi'] /** @type {number} */ var n = map2._map['hi'] /** @type {number} */ var n = map._map2['hi'] /** * @class * @template T * @param {T} t */ function Cp(t) { this.x = 1 this.y = t } Cp.prototype = { m1() { return this.x }, m2() { this.z = this.x + 1; return this.y } } var cp = new Cp(1) /** @type {number} */ var n = cp.x /** @type {number} */ var n = cp.y /** @type {number} */ var n = cp.m1() /** @type {number} */ var n = cp.m2()
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccess.ts
TypeScript
class A { a: number; } class B extends A { b: number; } enum Compass { North, South, East, West } var numIndex: { [n: number]: string } = { 3: 'three', 'three': 'three' }; var strIndex: { [n: string]: Compass } = { 'N': Compass.North, 'E': Compass.East }; var bothIndex: { [n: string]: A; [m: number]: B; }; function noIndex() { } var obj = { 10: 'ten', x: 'hello', y: 32, z: { n: 'world', m: 15, o: () => false }, 'literal property': 100 }; var anyVar: any = {}; var stringOrNumber: string | number; var someObject: { name: string }; // Assign to a property access obj.y = 4; // Property access on value of type 'any' anyVar.x = anyVar.y = obj.x = anyVar.z; // Dotted property access of property that exists var aa = obj.x; // Dotted property access of property that exists on value's apparent type var bb = obj.hasOwnProperty; // Dotted property access of property that doesn't exist on value's apparent type var cc = obj.qqq; // error // Bracket notation property access using string literal value on type with property of that literal name var dd = obj['literal property']; var dd: number; // Bracket notation property access using string literal value on type without property of that literal name var ee = obj['wa wa wa wa wa']; var ee: any; // Bracket notation property access using numeric string literal value on type with property of that literal name var ff = obj['10']; var ff: string; // Bracket notation property access using numeric string literal value on type without property of that literal name var gg = obj['1']; var gg: any; // Bracket notation property access using numeric value on type with numeric index signature var hh = numIndex[3.0]; var hh: string; // Bracket notation property access using enum value on type with numeric index signature var ii = numIndex[Compass.South]; var ii: string; // Bracket notation property access using value of type 'any' on type with numeric index signature var jj = numIndex[anyVar]; var jj: string; // Bracket notation property access using string value on type with numeric index signature var kk = numIndex['what']; var kk: any; // Bracket notation property access using value of other type on type with numeric index signature and no string index signature var ll = numIndex[someObject]; // Error // Bracket notation property access using string value on type with string index signature and no numeric index signature var mm = strIndex['N']; var mm: Compass; var mm2 = strIndex['zzz']; var mm2: Compass; // Bracket notation property access using numeric value on type with string index signature and no numeric index signature var nn = strIndex[10]; var nn: Compass; // Bracket notation property access using enum value on type with string index signature and no numeric index signature var oo = strIndex[Compass.East]; var oo: Compass; // Bracket notation property access using value of type 'any' on type with string index signature and no numeric index signature var pp = strIndex[<any>null]; var pp: Compass; // Bracket notation property access using numeric value on type with no index signatures var qq = noIndex[123]; var qq: any; // Bracket notation property access using string value on type with no index signatures var rr = noIndex['zzzz']; var rr: any; // Bracket notation property access using enum value on type with no index signatures var ss = noIndex[Compass.South]; var ss: any; // Bracket notation property access using value of type 'any' on type with no index signatures var tt = noIndex[<any>null]; var tt: any; // Bracket notation property access using values of other types on type with no index signatures var uu = noIndex[someObject]; // Error // Bracket notation property access using numeric value on type with numeric index signature and string index signature var vv = noIndex[32]; var vv: any; // Bracket notation property access using enum value on type with numeric index signature and string index signature var ww = bothIndex[Compass.East]; var ww: B; // Bracket notation property access using value of type 'any' on type with numeric index signature and string index signature var xx = bothIndex[<any>null]; var xx: B; // Bracket notation property access using string value on type with numeric index signature and string index signature var yy = bothIndex['foo']; var yy: A; // Bracket notation property access using numeric string value on type with numeric index signature and string index signature var zz = bothIndex['1.0']; var zz: A; // Bracket notation property access using value of other type on type with numeric index signature and no string index signature and string index signature var zzzz = bothIndex[someObject]; // Error var x1 = numIndex[stringOrNumber]; var x1: any; var x2 = strIndex[stringOrNumber]; var x2: Compass; var x3 = bothIndex[stringOrNumber]; var x3: A;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessChain.2.ts
TypeScript
// @strict: false declare const o1: undefined | { b: string }; o1?.b; declare const o2: undefined | { b: { c: string } }; o2?.b.c; declare const o3: { b: undefined | { c: string } }; o3.b?.c;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessChain.3.ts
TypeScript
// @strict: true declare const obj: any; obj?.a++; obj?.a.b++; obj?.a--; obj?.a.b--; ++obj?.a; ++obj?.a.b; --obj?.a; --obj?.a.b; obj?.a = 1; obj?.a.b = 1; obj?.a += 1; obj?.a.b += 1; for (obj?.a in {}); for (obj?.a.b in {}); for (obj?.a of []); for (obj?.a.b of []); ({ a: obj?.a } = { a: 1 }); ({ a: obj?.a.b } = { a: 1 }); ({ ...obj?.a } = { a: 1 }); ({ ...obj?.a.b } = { a: 1 }); [...obj?.a] = []; [...obj?.a.b] = [];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessChain.ts
TypeScript
// @strict: true declare const o1: undefined | { b: string }; o1?.b; declare const o2: undefined | { b: { c: string } }; o2?.b.c; declare const o3: { b: undefined | { c: string } }; o3.b?.c; declare const o4: { b?: { c: { d?: { e: string } } } }; o4.b?.c.d?.e; declare const o5: { b?(): { c: { d?: { e: string } } } }; o5.b?.().c.d?.e; // GH#33744 declare const o6: <T>() => undefined | ({ x: number }); o6<number>()?.x; // GH#34109 o1?.b ? 1 : 0; // GH#36031 o2?.b!.c; o2?.b!.c!;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessNumericLiterals.es6.ts
TypeScript
// @target: es6 0xffffffff.toString(); 0o01234.toString(); 0b01101101.toString(); 1234..toString(); 1e0.toString();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessOnTypeParameterWithConstraints.ts
TypeScript
// generic types should behave as if they have properties of their constraint type // no errors expected class C<T extends Date> { f() { var x: T; var a = x['getDate'](); // number return a + x.getDate(); } } var r = (new C<Date>()).f(); interface I<T extends Date> { foo: T; } var i: I<Date>; var r2 = i.foo.getDate(); var r2b = i.foo['getDate'](); var a: { <T extends Date>(): T; } var r3 = a<Date>().getDate(); var r3b = a()['getDate'](); var b = { foo: <T extends Date>(x: T) => { var a = x['getDate'](); // number return a + x.getDate(); } } var r4 = b.foo(new Date());
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessOnTypeParameterWithConstraints2.ts
TypeScript
// generic types should behave as if they have properties of their constraint type class A { foo(): string { return ''; } } class B extends A { bar(): string { return ''; } } class C<U extends A, T extends A> { f() { var x: U; var a = x['foo'](); // should be string return a + x.foo(); } g(x: U) { var a = x['foo'](); // should be string return a + x.foo(); } } //class C<U extends T, T extends A> { // f() { // var x: U; // var a = x['foo'](); // should be string // return a + x.foo(); // } // g(x: U) { // var a = x['foo'](); // should be string // return a + x.foo(); // } //} var r1 = (new C<B, A>()).f(); var r1b = (new C<B, A>()).g(new B()); interface I<U extends A, T extends A> { foo: U; } //interface I<U extends T, T extends A> { // foo: U; //} var i: I<B, A>; var r2 = i.foo.foo(); var r2b = i.foo['foo'](); var a: { <U extends A, T extends A>(): U; <U extends A, T extends A>(x: U): U; <U extends A, T extends A>(x: U, y: T): U; } //var a: { // <U extends T, T extends A>(): U; // <U extends T, T extends A>(x: U): U; // <U extends T, T extends A>(x: U, y: T): U; //} var r3 = a<A, A>().foo(); var r3b = a()['foo'](); // parameter supplied for type argument inference to succeed var aB = new B(); var r3c = a(aB, aB).foo(); var r3d = a(aB, aB)['foo'](); var b = { foo: <U extends A, T extends A>(x: U, y: T) => { var a = x['foo'](); // should be string return a + x.foo(); } } //var b = { // foo: <U extends T, T extends A>(x: U, y: T) => { // var a = x['foo'](); // should be string // return a + x.foo(); // } //} var r4 = b.foo(aB, aB); // no inferences for T so constraint isn't satisfied, error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessOnTypeParameterWithConstraints3.ts
TypeScript
// generic types should behave as if they have properties of their constraint type class A { foo(): string { return ''; } } class B extends A { bar(): string { return ''; } } class C<U extends A, T extends U> { f() { var x: T; // BUG 823818 var a = x['foo'](); // should be string return a + x.foo(); } g(x: U) { // BUG 823818 var a = x['foo'](); // should be string return a + x.foo(); } } var r1a = (new C<A, B>()).f(); var r1b = (new C<A, B>()).g(new B()); interface I<U extends A, T extends U> { foo: T; } var i: I<A, B>; var r2 = i.foo.foo(); var r2b = i.foo['foo'](); var a: { <U extends A, T extends U>(): T; <U extends T, T extends A>(x: U): U; } var r3 = a().foo(); // error, no inferences for U so it doesn't satisfy constraint var r3b = a()['foo'](); // parameter supplied for type argument inference for U var r3c = a(new B()).foo(); // valid call to an invalid function, U is inferred as B, which has a foo var r3d = a(new B())['foo'](); // valid call to an invalid function, U is inferred as B, which has a foo var b = { foo: <U extends A, T extends U>(x: T) => { // BUG 823818 var a = x['foo'](); // should be string return a + x.foo(); } } var r4 = b.foo(new B()); // valid call to an invalid function
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessOnTypeParameterWithConstraints4.ts
TypeScript
class C<T extends Date> { f() { var x: T; var a = x['notHere'](); // should be string return a + x.notHere(); } } var r = (new C<Date>()).f(); interface I<T extends Date> { foo: T; } var i: I<Date>; var r2 = i.foo.notHere(); var r2b = i.foo['notHere'](); var a: { <T extends Date>(): T; } var r3: string = a().notHere(); var r3b: string = a()['notHere'](); var b = { foo: <T extends Date>(x: T): T => { var a = x['notHere'](); // should be string return a + x.notHere(); }, bar: b.foo().notHere() } var r4 = b.foo(new Date());
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessOnTypeParameterWithConstraints5.ts
TypeScript
class A { foo(): string { return ''; } } class B extends A { bar(): string { return ''; } } class C<U extends T, T extends A> { f() { var x: U; var a = x['foo'](); // should be string return a + x.foo() + x.notHere(); } } var r = (new C<B, A>()).f(); interface I<U extends T, T extends A> { foo: U; } var i: I<B, A>; var r2 = i.foo.notHere(); var r2b = i.foo['foo'](); var a: { <U extends T, T extends A>(): U; } // BUG 794164 var r3: string = a().notHere(); var r3b: string = a()['foo'](); var b = { foo: <U extends T, T extends A>(x: U): U => { var a = x['foo'](); // should be string return a + x.notHere(); }, // BUG 794164 bar: b.foo(1).notHere() } var r4 = b.foo(new B()); // error after constraints above made illegal, doesn't matter
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessOnTypeParameterWithoutConstraints.ts
TypeScript
class C<T> { f() { var x: T; var a = x['toString'](); // should be string return a + x.toString(); } } var r = (new C<number>()).f(); interface I<T> { foo: T; } var i: I<number>; var r2 = i.foo.toString(); var r2b = i.foo['toString'](); var a: { <T>(): T; } var r3: string = a().toString(); var r3b: string = a()['toString'](); var b = { foo: <T>(x: T) => { var a = x['toString'](); // should be string return a + x.toString(); } } var r4 = b.foo(1);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessStringIndexSignature.ts
TypeScript
interface Flags { [name: string]: boolean }; let flags: Flags; flags.b; flags.f; flags.isNotNecessarilyNeverFalse; flags['this is fine']; interface Empty { } let empty: Empty; empty.nope; empty["that's ok"];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessStringIndexSignatureNoImplicitAny.ts
TypeScript
// @noImplicitAny: true interface Flags { [name: string]: boolean } let flags: Flags; flags.b; flags.f; flags.isNotNecessarilyNeverFalse; flags['this is fine']; interface Empty { } let empty: Empty; empty.nope; empty["not allowed either"];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAccessWidening.ts
TypeScript
// @strict: true // Repro from #31762 function g1(headerNames: any) { let t = [{ hasLineBreak: false, cells: [] }]; const table = [{cells: headerNames }].concat(t); } function g2(headerNames: any) { let t = [{ hasLineBreak: false, cells: [] }]; const table = [{cells: headerNames }]["concat"](t); } // Object in property or element access is widened when target of assignment function foo(options?: { a: string, b: number }) { let x1 = (options || {}).a; // Object type not widened let x2 = (options || {})["a"]; // Object type not widened (options || {}).a = 1; // Object type widened, error (options || {})["a"] = 1; // Object type widened, error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAndAccessorWithSameName.ts
TypeScript
class C { x: number; get x() { // error return 1; } } class D { x: number; set x(v) { } // error } class E { private x: number; get x() { // error return 1; } set x(v) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAndFunctionWithSameName.ts
TypeScript
class C { x: number; x() { // error return 1; } } class D { x: number; x(v) { } // error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAssignmentOnImportedSymbol.ts
TypeScript
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: mod1.js export var hurk = {} // @Filename: bug24658.js import { hurk } from './mod1' hurk.expando = 4
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAssignmentOnParenthesizedNumber.ts
TypeScript
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: bug38934.js var x = {}; // should not crash and also should not result in a property '0' on x. x[(0)] = 1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAssignmentOnUnresolvedImportedSymbol.ts
TypeScript
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: bug28576.js import x from 'arglebaz' { x.bar = 1 }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAssignmentUseParentType1.ts
TypeScript
interface N { (): boolean num: 123; } export const interfaced: N = () => true; interfaced.num = 123; export const inlined: { (): boolean; nun: 456 } = () => true; inlined.nun = 456; export const ignoreJsdoc = () => true; /** @type {string} make sure to ignore jsdoc! */ ignoreJsdoc.extra = 111
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAssignmentUseParentType2.ts
TypeScript
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: propertyAssignmentUseParentType2.js /** @type {{ (): boolean; nuo: 789 }} */ export const inlined = () => true inlined.nuo = 789 /** @type {{ (): boolean; nuo: 789 }} */ export const duplicated = () => true /** @type {789} */ duplicated.nuo = 789 /** @type {{ (): boolean; nuo: 789 }} */ export const conflictingDuplicated = () => true /** @type {1000} */ conflictingDuplicated.nuo = 789
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyAssignmentUseParentType3.ts
TypeScript
// don't use the parent type if it's a function declaration (#33741) function foo1(): number { return 123; } foo1.toFixed = ""; function foo2(): any[] { return []; } foo2.join = ""; function foo3(): string { return ""; } foo3.trim = ""; function foo4(): ({x: number}) { return {x: 123}; } foo4.x = "456";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyNameWithoutTypeAnnotation.ts
TypeScript
class C { foo; } interface I { foo; } var a: { foo; } var b = { foo: null } // These should all be of type 'any' var r1 = (new C()).foo; var r2 = (<I>null).foo; var r3 = a.foo; var r4 = b.foo;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyNamedPrototype.ts
TypeScript
class C { prototype: number; // ok static prototype: C; // error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyNamesOfReservedWords.ts
TypeScript
class C { abstract; as; boolean; break; byte; case; catch; char; class; continue; const; debugger; default; delete; do; double; else; enum; export; extends; false; final; finally; float; for; function; goto; if; implements; import; in; instanceof; int; interface; is; long; namespace; native; new; null; package; private; protected; public; return; short; static; super; switch; synchronized; this; throw; throws; transient; true; try; typeof; use; var; void; volatile; while; with; } var c: C; var r1 = c.abstract; var r2 = c.as; interface I { abstract; as; boolean; break; byte; case; catch; char; class; continue; const; debugger; default; delete; do; double; else; enum; export; extends; false; final; finally; float; for; function; goto; if; implements; import; in; instanceof; int; interface; is; long; namespace; native; new; null; package; private; protected; public; return; short; static; super; switch; synchronized; this; throw; throws; transient; true; try; typeof; use; var; void; volatile; while; with; } var i: I; var r3 = i.abstract; var r4 = i.as; var a: { abstract; as; boolean; break; byte; case; catch; char; class; continue; const; debugger; default; delete; do; double; else; enum; export; extends; false; final; finally; float; for; function; goto; if; implements; import; in; instanceof; int; interface; is; long; namespace; native; new; null; package; private; protected; public; return; short; static; super; switch; synchronized; this; throw; throws; transient; true; try; typeof; use; var; void; volatile; while; with; } var r5 = a.abstract; var r6 = a.as; enum E { abstract, as, boolean, break, byte, case, catch, char, class, continue, const, debugger, default, delete, do, double, else, enum, export, extends, false, final, finally, float, for, function, goto, if, implements, import, in, instanceof, int, interface, is, long, namespace, native, new, null, package, private, protected, public, return, short, static, super, switch, synchronized, this, throw, throws, transient, true, try, typeof, use, var, void, volatile, while, with, } var r7 = E.abstract; var r8 = E.as;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University