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/propertyOverridesAccessors.ts
TypeScript
// @target: es2015 // @useDefineForClassFields: true class A { get p() { return 'oh no' } } class B extends A { p = 'yep' // error } class C { _secret = 11 get p() { return this._secret } set p(value) { this._secret = value } } class D extends C { p = 101 // error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyOverridesAccessors2.ts
TypeScript
// @target: esnext // @useDefineForClassFields: true class Base { get x() { return 2; } set x(value) { console.log(`x was set to ${value}`); } } class Derived extends Base { x = 1; } const obj = new Derived(); // prints 'x was set to 1' console.log(obj.x); // 2
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyOverridesAccessors3.ts
TypeScript
// @target: esnext // @useDefineForClassFields: true class Animal { _sound = 'rustling noise in the bushes' get sound() { return this._sound } set sound(val) { this._sound = val; /* some important code here, perhaps tracking known sounds, etc */ } makeSound() { console.log(this._sound) } } const a = new Animal a.makeSound() // 'rustling noise in the bushes' class Lion extends Animal { sound = 'RAWR!' // error here } const lion = new Lion lion.makeSound() // with [[Define]]: Expected "RAWR!" but got "rustling noise in the bushes"
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyOverridesAccessors4.ts
TypeScript
// @target: es5 // @useDefineForClassFields: true declare class Animal { get sound(): string set sound(val: string) } class Lion extends Animal { sound = 'RAWR!' // error here }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyOverridesAccessors5.ts
TypeScript
// @target: esnext // @useDefineForClassFields: true class A { get p() { return 'oh no' } } class B extends A { constructor(public p: string) { super() } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/propertyOverridesMethod.ts
TypeScript
// @target: esnext // @useDefineForClassFields: true class A { m() { } } class B extends A { m = () => 1 }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/protectedClassPropertyAccessibleWithinClass.ts
TypeScript
// @target: ES5 // no errors class C { protected x: string; protected get y() { return this.x; } protected set y(x) { this.y = this.x; } protected foo() { return this.foo; } protected static x: string; protected static get y() { return this.x; } protected static set y(x) { this.y = this.x; } protected static foo() { return this.foo; } protected static bar() { this.foo(); } } // added level of function nesting class C2 { protected x: string; protected get y() { () => this.x; return null; } protected set y(x) { () => { this.y = this.x; } } protected foo() { () => this.foo; } protected static x: string; protected static get y() { () => this.x; return null; } protected static set y(x) { () => { this.y = this.x; } } protected static foo() { () => this.foo; } protected static bar() { () => this.foo(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/protectedClassPropertyAccessibleWithinNestedClass.ts
TypeScript
// @target: ES5 // no errors class C { protected x: string; protected get y() { return this.x; } protected set y(x) { this.y = this.x; } protected foo() { return this.foo; } protected static x: string; protected static get y() { return this.x; } protected static set y(x) { this.y = this.x; } protected static foo() { return this.foo; } protected static bar() { this.foo(); } protected bar() { class C2 { protected foo() { let x: C; var x1 = x.foo; var x2 = x.bar; var x3 = x.x; var x4 = x.y; var sx1 = C.x; var sx2 = C.y; var sx3 = C.bar; var sx4 = C.foo; let y = new C(); var y1 = y.foo; var y2 = y.bar; var y3 = y.x; var y4 = y.y; } } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/protectedClassPropertyAccessibleWithinNestedSubclass.ts
TypeScript
// @target: ES5 class B { protected x: string; protected static x: string; } class C extends B { protected get y() { return this.x; } protected set y(x) { this.y = this.x; } protected foo() { return this.x; } protected static get y() { return this.x; } protected static set y(x) { this.y = this.x; } protected static foo() { return this.x; } protected static bar() { this.foo(); } protected bar() { class D { protected foo() { var c = new C(); var c1 = c.y; var c2 = c.x; var c3 = c.foo; var c4 = c.bar; var c5 = c.z; // error var sc1 = C.x; var sc2 = C.y; var sc3 = C.foo; var sc4 = C.bar; } } } } class E extends C { protected z: string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/protectedClassPropertyAccessibleWithinNestedSubclass1.ts
TypeScript
class Base { protected x: string; method() { class A { methoda() { var b: Base; var d1: Derived1; var d2: Derived2; var d3: Derived3; var d4: Derived4; b.x; // OK, accessed within their declaring class d1.x; // OK, accessed within their declaring class d2.x; // OK, accessed within their declaring class d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses d4.x; // OK, accessed within their declaring class } } } } class Derived1 extends Base { method1() { class B { method1b() { var b: Base; var d1: Derived1; var d2: Derived2; var d3: Derived3; var d4: Derived4; b.x; // Error, isn't accessed through an instance of the enclosing class d1.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class d2.x; // Error, isn't accessed through an instance of the enclosing class d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses d4.x; // Error, isn't accessed through an instance of the enclosing class } } } } class Derived2 extends Base { method2() { class C { method2c() { var b: Base; var d1: Derived1; var d2: Derived2; var d3: Derived3; var d4: Derived4; b.x; // Error, isn't accessed through an instance of the enclosing class d1.x; // Error, isn't accessed through an instance of the enclosing class d2.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses d4.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class or one of its subclasses } } } } class Derived3 extends Derived1 { protected x: string; method3() { class D { method3d() { var b: Base; var d1: Derived1; var d2: Derived2; var d3: Derived3; var d4: Derived4; b.x; // Error, isn't accessed through an instance of the enclosing class d1.x; // Error, isn't accessed through an instance of the enclosing class d2.x; // Error, isn't accessed through an instance of the enclosing class d3.x; // OK, accessed within their declaring class d4.x; // Error, isn't accessed through an instance of the enclosing class } } } } class Derived4 extends Derived2 { method4() { class E { method4e() { var b: Base; var d1: Derived1; var d2: Derived2; var d3: Derived3; var d4: Derived4; b.x; // Error, isn't accessed through an instance of the enclosing class d1.x; // Error, isn't accessed through an instance of the enclosing class d2.x; // Error, isn't accessed through an instance of the enclosing class d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses d4.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class } } } } var b: Base; var d1: Derived1; var d2: Derived2; var d3: Derived3; var d4: Derived4; b.x; // Error, neither within their declaring class nor classes derived from their declaring class d1.x; // Error, neither within their declaring class nor classes derived from their declaring class d2.x; // Error, neither within their declaring class nor classes derived from their declaring class d3.x; // Error, neither within their declaring class nor classes derived from their declaring class d4.x; // Error, neither within their declaring class nor classes derived from their declaring class
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/protectedClassPropertyAccessibleWithinSubclass.ts
TypeScript
// @target: ES5 // no errors class B { protected x: string; protected static x: string; } class C extends B { protected get y() { return this.x; } protected set y(x) { this.y = this.x; } protected foo() { return this.x; } protected bar() { return this.foo(); } protected static get y() { return this.x; } protected static set y(x) { this.y = this.x; } protected static foo() { return this.x; } protected static bar() { this.foo(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/protectedClassPropertyAccessibleWithinSubclass2.ts
TypeScript
class Base { protected x: string; method() { var b: Base; var d1: Derived1; var d2: Derived2; var d3: Derived3; var d4: Derived4; b.x; // OK, accessed within their declaring class d1.x; // OK, accessed within their declaring class d2.x; // OK, accessed within their declaring class d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses d4.x; // OK, accessed within their declaring class } } class Derived1 extends Base { method1() { var b: Base; var d1: Derived1; var d2: Derived2; var d3: Derived3; var d4: Derived4; b.x; // Error, isn't accessed through an instance of the enclosing class d1.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class d2.x; // Error, isn't accessed through an instance of the enclosing class d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses d4.x; // Error, isn't accessed through an instance of the enclosing class } } class Derived2 extends Base { method2() { var b: Base; var d1: Derived1; var d2: Derived2; var d3: Derived3; var d4: Derived4; b.x; // Error, isn't accessed through an instance of the enclosing class d1.x; // Error, isn't accessed through an instance of the enclosing class d2.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses d4.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class or one of its subclasses } } class Derived3 extends Derived1 { protected x: string; method3() { var b: Base; var d1: Derived1; var d2: Derived2; var d3: Derived3; var d4: Derived4; b.x; // Error, isn't accessed through an instance of the enclosing class d1.x; // Error, isn't accessed through an instance of the enclosing class d2.x; // Error, isn't accessed through an instance of the enclosing class d3.x; // OK, accessed within their declaring class d4.x; // Error, isn't accessed through an instance of the enclosing class } } class Derived4 extends Derived2 { method4() { var b: Base; var d1: Derived1; var d2: Derived2; var d3: Derived3; var d4: Derived4; b.x; // Error, isn't accessed through an instance of the enclosing class d1.x; // Error, isn't accessed through an instance of the enclosing class d2.x; // Error, isn't accessed through an instance of the enclosing class d3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses d4.x; // OK, accessed within a class derived from their declaring class, and through an instance of the enclosing class } } var b: Base; var d1: Derived1; var d2: Derived2; var d3: Derived3; var d4: Derived4; b.x; // Error, neither within their declaring class nor classes derived from their declaring class d1.x; // Error, neither within their declaring class nor classes derived from their declaring class d2.x; // Error, neither within their declaring class nor classes derived from their declaring class d3.x; // Error, neither within their declaring class nor classes derived from their declaring class d4.x; // Error, neither within their declaring class nor classes derived from their declaring class
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/protectedClassPropertyAccessibleWithinSubclass3.ts
TypeScript
class Base { protected x: string; method() { this.x; // OK, accessed within their declaring class } } class Derived extends Base { method1() { this.x; // OK, accessed within a subclass of the declaring class super.x; // Error, x is not public } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/protectedInstanceMemberAccessibility.ts
TypeScript
class A { protected x: string; protected f(): string { return "hello"; } } class B extends A { protected y: string; g() { var t1 = this.x; var t2 = this.f(); var t3 = this.y; var t4 = this.z; // error var s1 = super.x; // error var s2 = super.f(); var s3 = super.y; // error var s4 = super.z; // error var a: A; var a1 = a.x; // error var a2 = a.f(); // error var a3 = a.y; // error var a4 = a.z; // error var b: B; var b1 = b.x; var b2 = b.f(); var b3 = b.y; var b4 = b.z; // error var c: C; var c1 = c.x; // error var c2 = c.f(); // error var c3 = c.y; // error var c4 = c.z; // error } } class C extends A { protected z: string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/protectedStaticClassPropertyAccessibleWithinSubclass.ts
TypeScript
class Base { protected static x: string; static staticMethod() { Base.x; // OK, accessed within their declaring class Derived1.x; // OK, accessed within their declaring class Derived2.x; // OK, accessed within their declaring class Derived3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses } } class Derived1 extends Base { static staticMethod1() { Base.x; // OK, accessed within a class derived from their declaring class Derived1.x; // OK, accessed within a class derived from their declaring class Derived2.x; // OK, accessed within a class derived from their declaring class Derived3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses } } class Derived2 extends Base { static staticMethod2() { Base.x; // OK, accessed within a class derived from their declaring class Derived1.x; // OK, accessed within a class derived from their declaring class Derived2.x; // OK, accessed within a class derived from their declaring class Derived3.x; // Error, redefined in a subclass, can only be accessed in the declaring class or one of its subclasses } } class Derived3 extends Derived1 { protected static x: string; static staticMethod3() { Base.x; // OK, accessed within a class derived from their declaring class Derived1.x; // OK, accessed within a class derived from their declaring class Derived2.x; // OK, accessed within a class derived from their declaring class Derived3.x; // OK, accessed within their declaring class } } Base.x; // Error, neither within their declaring class nor classes derived from their declaring class Derived1.x; // Error, neither within their declaring class nor classes derived from their declaring class Derived2.x; // Error, neither within their declaring class nor classes derived from their declaring class Derived3.x; // Error, neither within their declaring class nor classes derived from their declaring class
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/protectedStaticClassPropertyAccessibleWithinSubclass2.ts
TypeScript
class Base { protected static x: string; static staticMethod() { this.x; // OK, accessed within their declaring class } } class Derived1 extends Base { static staticMethod1() { this.x; // OK, accessed within a class derived from their declaring class super.x; // Error, x is not public } } class Derived2 extends Derived1 { protected static x: string; static staticMethod3() { this.x; // OK, accessed within a class derived from their declaring class super.x; // Error, x is not public } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/protectedStaticNotAccessibleInClodule.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 { public static foo: string; protected static bar: string; } module C { export var f = C.foo; // OK export var b = C.bar; // error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/prototypePropertyAssignmentMergeAcrossFiles.ts
TypeScript
// @Filename: prototypePropertyAssignmentMergeAcrossFiles.js // @allowJs: true // @checkJs: true // @noEmit: true function C() { this.a = 1 } // @Filename: other.js C.prototype.foo = function() { return this.a }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/prototypePropertyAssignmentMergeAcrossFiles2.ts
TypeScript
// @Filename: prototypePropertyAssignmentMergeAcrossFiles2.js // @allowJs: true // @checkJs: true // @noEmit: true var Ns = {} Ns.One = function() {}; Ns.Two = function() {}; Ns.One.prototype = { ok() {}, }; Ns.Two.prototype = { } // @Filename: other.js /** * @type {Ns.One} */ var one; one.wat; /** * @type {Ns.Two} */ var two; two.wat;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/prototypePropertyAssignmentMergeWithInterfaceMethod.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: lovefield-ts.d.ts // bug #27352, crashes from github.com/google/lovefield declare namespace lf { export interface Transaction { attach(query: query.Builder): Promise<Array<Object>> begin(scope: Array<schema.Table>): Promise<void> commit(): Promise<void> exec(queries: Array<query.Builder>): Promise<Array<Array<Object>>> rollback(): Promise<void> stats(): TransactionStats } } // @Filename: lovefield.js lf.Transaction = function() {}; /** * @param {!Array<!lf.schema.Table>} scope * @return {!IThenable} */ lf.Transaction.prototype.begin = function(scope) {};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/prototypePropertyAssignmentMergedTypeReference.ts
TypeScript
// https://github.com/microsoft/TypeScript/issues/33993 // @noEmit: true // @allowJs: true // @checkJS: true // @filename: prototypePropertyAssignmentMergedTypeReference.js var f = function() { return 12; }; f.prototype.a = "a"; /** @type {new () => f} */ var x = f;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/quotedConstructors.ts
TypeScript
class C { "constructor"() { console.log(this); } } class D { 'constructor'() { console.log(this); } } class E { ['constructor']() { console.log(this); } } new class { "constructor"() { console.log(this); } }; var o = { "constructor"() {} }; class F { "\x63onstructor"() { console.log(this); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/reExportAliasMakesInstantiated.ts
TypeScript
declare module pack1 { const test1: string; export { test1 }; } declare module pack2 { import test1 = pack1.test1; export { test1 }; } export import test1 = pack2.test1; declare module mod1 { type test1 = string; export { test1 }; } declare module mod2 { import test1 = mod1.test1; export { test1 }; } const test2 = mod2; // Possible false positive instantiation, but ok
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/reExportDefaultExport.ts
TypeScript
// @module: commonjs // @target: ES5 // @filename: m1.ts export default function f() { } export {f}; // @filename: m2.ts import foo from "./m1"; import {f} from "./m1"; f(); foo();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/reExportJsFromTs.ts
TypeScript
// @allowJs: true // @outDir: out // @Filename: /lib/constants.js module.exports = { str: 'x', }; // @Filename: /src/constants.ts import * as tsConstants from "../lib/constants"; export { tsConstants };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/readonlyArraysAndTuples2.ts
TypeScript
// @strict: true // @declaration: true // @emitDecoratorMetadata: true // @experimentalDecorators: true type T10 = string[]; type T11 = Array<string>; type T12 = readonly string[]; type T13 = ReadonlyArray<string>; type T20 = [number, number]; type T21 = readonly [number, number]; declare function f1(ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]): readonly [string, string]; declare const someDec: any; class A { @someDec j: readonly string[] = []; @someDec k: readonly [string, number] = ['foo', 42]; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/readonlyConstructorAssignment.ts
TypeScript
// Tests that readonly parameter properties behave like regular readonly properties class A { constructor(readonly x: number) { this.x = 0; } } class B extends A { constructor(x: number) { super(x); // Fails, x is readonly this.x = 1; } } class C extends A { // This is the usual behavior of readonly properties: // if one is redeclared in a base class, then it can be assigned to. constructor(readonly x: number) { super(x); this.x = 1; } } class D { constructor(private readonly x: number) { this.x = 0; } } // Fails, can't redeclare readonly property class E extends D { constructor(readonly x: number) { super(x); this.x = 1; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/readonlyInAmbientClass.ts
TypeScript
declare class C{ constructor(readonly x: number); method(readonly x: number); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/readonlyRestParameters.ts
TypeScript
// @strict: true // @declaration: true function f0(a: string, b: string) { f0(a, b); f1(a, b); f2(a, b); } function f1(...args: readonly string[]) { f0(...args); // Error f1('abc', 'def'); f1('abc', ...args); f1(...args); } function f2(...args: readonly [string, string]) { f0(...args); f1('abc', 'def'); f1('abc', ...args); f1(...args); f2('abc', 'def'); f2('abc', ...args); // Error f2(...args); } function f4(...args: readonly string[]) { args[0] = 'abc'; // Error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/recurringTypeParamForContainerOfBase01.ts
TypeScript
// @declaration: true interface BoxOfFoo<T extends Foo<T>> { item: T } interface Foo<T extends Foo<T>> { self: T; } interface Bar<T extends Bar<T>> extends Foo<T> { other: BoxOfFoo<T>; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/recursiveInitializer.ts
TypeScript
// number unless otherwise specified var n1 = n1++; var n2: number = n2 + n2; var n3 /* any */ = n3 + n3; // string unless otherwise specified var s1 = s1 + ''; var s2 /* any */ = s2 + s2; var s3 : string = s3 + s3; var s4 = '' + s4; // boolean unless otherwise specified var b1 = !b1; var b2 = !!b2; var b3 = !b3 || b3; // expected boolean here. actually 'any' var b4 = (!b4) && b4; // expected boolean here. actually 'any' // (x:string) => any var f = (x: string) => f(x);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/recursiveIntersectionTypes.ts
TypeScript
type LinkedList<T> = T & { next: LinkedList<T> }; interface Entity { name: string; } interface Product extends Entity { price: number; } var entityList: LinkedList<Entity>; var s = entityList.name; var s = entityList.next.name; var s = entityList.next.next.name; var s = entityList.next.next.next.name; var productList: LinkedList<Product>; entityList = productList; productList = entityList; // Error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/recursiveMappedTypes.ts
TypeScript
// @declaration: true // Recursive mapped types simply appear empty type Recurse = { [K in keyof Recurse]: Recurse[K] } type Recurse1 = { [K in keyof Recurse2]: Recurse2[K] } type Recurse2 = { [K in keyof Recurse1]: Recurse1[K] } // Repro from #27881 export type Circular<T> = {[P in keyof T]: Circular<T>}; type tup = [number, number, number, number]; function foo(arg: Circular<tup>): tup { return arg; } // Repro from #29442 type DeepMap<T extends unknown[], R> = { [K in keyof T]: T[K] extends unknown[] ? DeepMap<T[K], R> : R; }; type tpl = [string, [string, [string]]]; type arr = string[][]; type t1 = DeepMap<tpl, number>; // [number, [number, [number]]] type t2 = DeepMap<arr, number>; // number[][] // Repro from #29577 type Transform<T> = { [K in keyof T]: Transform<T[K]> }; interface User { avatar: string; } interface Guest { displayName: string; } interface Product { users: (User | Guest)[]; } declare var product: Transform<Product>; product.users; // (Transform<User> | Transform<Guest>)[] // Repro from #29702 type Remap1<T> = { [P in keyof T]: Remap1<T[P]>; }; type Remap2<T> = T extends object ? { [P in keyof T]: Remap2<T[P]>; } : T; type a = Remap1<string[]>; // string[] type b = Remap2<string[]>; // string[] // Repro from #29992 type NonOptionalKeys<T> = { [P in keyof T]: undefined extends T[P] ? never : P }[keyof T]; type Child<T> = { [P in NonOptionalKeys<T>]: T[P] } export interface ListWidget { "type": "list", "minimum_count": number, "maximum_count": number, "collapsable"?: boolean, //default to false, means all expanded "each": Child<ListWidget>; } type ListChild = Child<ListWidget> declare let x: ListChild; x.type; // Repros from #41790 export type TV<T, K extends keyof T> = T[K] extends Record<infer E, any> ? E : never; export type ObjectOrArray<T, K extends keyof any = keyof any> = T[] | Record<K, T | Record<K, T> | T[]>; export type ThemeValue<K extends keyof ThemeType, ThemeType, TVal = any> = ThemeType[K] extends TVal[] ? number : ThemeType[K] extends Record<infer E, TVal> ? E : ThemeType[K] extends ObjectOrArray<infer F> ? F : never; export type Foo<T> = T extends { [P in infer E]: any } ? E : never;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/recursiveTypeInGenericConstraint.ts
TypeScript
class G<T> { x: G<G<T>>; // infinitely expanding type reference } class Foo<T extends G<T>> { // error, constraint referencing itself bar: T; } class D<T> { x: G<G<T>>; } var c1 = new Foo<D<string>>(); // ok, circularity in assignment compat check causes success
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/recursiveTypeReferences1.ts
TypeScript
// @strict: true // @declaration: true type ValueOrArray<T> = T | Array<ValueOrArray<T>>; const a0: ValueOrArray<number> = 1; const a1: ValueOrArray<number> = [1, [2, 3], [4, [5, [6, 7]]]]; type HypertextNode = string | [string, { [key: string]: unknown }, ...HypertextNode[]]; const hypertextNode: HypertextNode = ["div", { id: "parent" }, ["div", { id: "first-child" }, "I'm the first child"], ["div", { id: "second-child" }, "I'm the second child"] ]; type Json = string | number | boolean | null | Json[] | { [key: string]: Json }; let data: Json = { caption: "Test", location: { x: 10, y: 20 }, values: [true, [10, 20], null] }; interface Box<T> { value: T }; type T1 = Box<T1>; type T2 = Box<Box<T2>>; type T3 = Box<Box<Box<T3>>>; function f1(t1: T1, t2: T2, t3: T3) { t1 = t2; t1 = t3; t2 = t1; t2 = t3; t3 = t1; t3 = t2; } type Box1 = Box<Box1> | number; const b10: Box1 = 42; const b11: Box1 = { value: 42 }; const b12: Box1 = { value: { value: { value: 42 }}}; type Box2 = Box<Box2 | number>; const b20: Box2 = 42; // Error const b21: Box2 = { value: 42 }; const b22: Box2 = { value: { value: { value: 42 }}}; type RecArray<T> = Array<T | RecArray<T>>; declare function flat<T>(a: RecArray<T>): Array<T>; declare function flat1<T>(a: Array<T | Array<T>>): Array<T> declare function flat2<T>(a: Array<T | Array<T | Array<T>>>): Array<T>; flat([1, [2, [3]]]); // number[] flat([[[0]]]); // number[] flat([[[[[[[[[[[4]]]]]]]]]]]); // number[] flat([1, 'a', [2]]); // (string | number)[] flat([1, [2, 'a']]); // (string | number)[] flat([1, ['a']]); // Error flat1([1, [2, [3]]]); // (number | number[])[] flat1([[[0]]]); // number[][] flat1([1, 'a', [2]]); // (string | number)[] flat1([1, [2, 'a']]); // (string | number)[] flat1([1, ['a']]); // Error flat2([1, [2, [3]]]); // number[] flat2([[[0]]]); // number[] flat2([1, 'a', [2]]); // (string | number)[] flat2([1, [2, 'a']]); // (string | number)[] flat2([1, ['a']]); // Error type T10 = T10[]; type T11 = readonly T11[]; type T12 = (T12)[]; type T13 = T13[] | string; type T14 = T14[] & { x: string }; type T15<X> = X extends string ? T15<X>[] : never; type ValueOrArray1<T> = T | ValueOrArray1<T>[]; type ValueOrArray2<T> = T | ValueOrArray2<T>[]; declare function foo1<T>(a: ValueOrArray1<T>): T; declare let ra1: ValueOrArray2<string>; let x1 = foo1(ra1); // Boom! type NumberOrArray1<T> = T | ValueOrArray1<T>[]; type NumberOrArray2<T> = T | ValueOrArray2<T>[]; declare function foo2<T>(a: ValueOrArray1<T>): T; declare let ra2: ValueOrArray2<string>; let x2 = foo2(ra2); // Boom! // Repro from #33617 (errors are expected) type Tree = [HTMLHeadingElement, Tree][]; function parse(node: Tree, index: number[] = []): HTMLUListElement { return html('ul', node.map(([el, children], i) => { const idx = [...index, i + 1]; return html('li', [ html('a', { href: `#${el.id}`, rel: 'noopener', 'data-index': idx.join('.') }, el.textContent!), children.length > 0 ? parse(children, idx) : frag() ]); })); } function cons(hs: HTMLHeadingElement[]): Tree { return hs .reduce<HTMLHeadingElement[][]>((hss, h) => { const hs = hss.pop()!; return hs.length === 0 || level(h) > level(hs[0]) ? concat(hss, [concat(hs, [h])]) : concat(hss, [hs, [h]]); }, [[]]) .reduce<Tree>((node, hs) => hs.length === 0 ? node : concat<Tree[number]>(node, [[hs.shift()!, cons(hs)]]) , []); } function level(h: HTMLHeadingElement): number { assert(isFinite(+h.tagName[1])); return +h.tagName[1]; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/recursiveTypeReferences2.ts
TypeScript
// @checkjs: true // @outdir: out/ // @filename: bug39372.js // @declaration: true /** @typedef {ReadonlyArray<Json>} JsonArray */ /** @typedef {{ readonly [key: string]: Json }} JsonRecord */ /** @typedef {boolean | number | string | null | JsonRecord | JsonArray | readonly []} Json */ /** * @template T * @typedef {{ $A: { [K in keyof T]?: XMLObject<T[K]>[] }, $O: { [K in keyof T]?: { $$?: Record<string, string> } & (T[K] extends string ? {$:string} : XMLObject<T[K]>) }, $$?: Record<string, string>, } & { [K in keyof T]?: ( T[K] extends string ? string : XMLObject<T[K]> ) }} XMLObject<T> */ /** @type {XMLObject<{foo:string}>} */ const p = {};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/recursiveTypesUsedAsFunctionParameters.ts
TypeScript
class List<T> { data: T; next: List<List<T>>; } class MyList<T> { data: T; next: MyList<MyList<T>>; } function foo<T>(x: List<T>); function foo<U>(x: List<U>); // error, duplicate function foo<T>(x: List<T>) { } function foo2<T>(x: List<T>); function foo2<U>(x: MyList<U>); // ok, nominally compared with first overload function foo2<T>(x: any) { } function other<T extends List<U>, U>() { // error but wrong error // BUG 838247 function foo3<V>(x: T); function foo3<V>(x: MyList<V>) { } // should be error // BUG 838247 function foo4<V>(x: T); function foo4<V>(x: List<V>) { } // ok function foo5<V>(x: T): string; function foo5<V>(x: List<V>): number; function foo5<V>(x: MyList<V>): boolean; function foo5<V>(x: any): any { return null; } var list: List<string>; var myList: MyList<string>; var r = foo5(list); var r2 = foo5(myList); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/recursiveTypesWithTypeof.ts
TypeScript
// The following are errors because of circular references var c: typeof c; var c: any; var d: typeof e; var d: any; var e: typeof d; var e: any; interface Foo<T> { } var f: Array<typeof f>; var f: any; var f2: Foo<typeof f2>; var f2: any; var f3: Foo<typeof f3>[]; var f3: any; // None of these declarations should have any errors! // Truly recursive types var g: { x: typeof g; }; var g: typeof g.x; var h: () => typeof h; var h = h(); var i: (x: typeof i) => typeof x; var i = i(i); var j: <T extends typeof j>(x: T) => T; var j = j(j); // Same as h, i, j with construct signatures var h2: new () => typeof h2; var h2 = new h2(); var i2: new (x: typeof i2) => typeof x; var i2 = new i2(i2); var j2: new <T extends typeof j2>(x: T) => T; var j2 = new j2(j2); // Indexers var k: { [n: number]: typeof k;[s: string]: typeof k }; var k = k[0]; var k = k['']; // Hybrid - contains type literals as well as type arguments // These two are recursive var hy1: { x: typeof hy1 }[]; var hy1 = hy1[0].x; var hy2: { x: Array<typeof hy2> }; var hy2 = hy2.x[0]; interface Foo2<T, U> { } // This one should be an error because the first type argument is not contained inside a type literal var hy3: Foo2<typeof hy3, { x: typeof hy3 }>; var hy3: any;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/redeclaredProperty.ts
TypeScript
// @noTypesAndSymbols: true // @strictNullChecks: true // @target: esnext // @useDefineForClassFields: true class Base { b = 1; } class Derived extends Base { b; d = this.b; constructor() { super(); this.b = 2; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/redefinedPararameterProperty.ts
TypeScript
// @noTypesAndSymbols: true // @strictNullChecks: true // @target: esnext // @useDefineForClassFields: true class Base { a = 1; } class Derived extends Base { b = this.a /*undefined*/; constructor(public a: number) { super(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/reexportClassDefinition.ts
TypeScript
// @module: commonjs // @Filename: foo1.ts class x{} export = x; // @Filename: foo2.ts import foo1 = require('./foo1'); export = { x: foo1 } // @Filename: foo3.ts import foo2 = require('./foo2') class x extends foo2.x {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/relativePathMustResolve.ts
TypeScript
// @module: commonjs // @Filename: foo_0.ts export var x = 42; // @Filename: foo_1.ts import foo = require('./test/foo'); var z = foo.x + 10;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/relativePathToDeclarationFile.ts
TypeScript
// @ModuleResolution: classic // @Filename: test/foo.d.ts export declare module M2 { export var x: boolean; } // @Filename: test/other.d.ts export declare module M2 { export var x: string; } // @Filename: test/sub/relMod.d.ts declare class Test { constructor(x: number); } export = Test; // @Filename: test/file1.ts import foo = require('foo'); import other = require('./other'); import relMod = require('./sub/relMod'); if(foo.M2.x){ var x = new relMod(other.M2.x.charCodeAt(0)); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/renamed.ts
TypeScript
// @strict: true // @Filename: /a.ts class A { a!: string } export type { A as B }; // @Filename: /b.ts export type { B as C } from './a'; // @Filename: /c.ts import type { C as D } from './b'; const d: D = {};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/requireAssertsFromTypescript.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: ex.d.ts // based on assert in @types/node export function art(value: any, message?: string | Error): asserts value; // @Filename: ex2.d.ts declare function art(value: any, message?: string | Error): asserts value; export = art; // @Filename: 38379.js const { art } = require('./ex') const artoo = require('./ex2') let x = 1 art(x) let y = 1 artoo(y)
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/requireOfESWithPropertyAccess.ts
TypeScript
// @allowJs: true // @checkJs: true // @strict: true // @outDir: out // @declaration: true // @filename: main.js const x = require('./ch').x x x.grey x.x.grey // @filename: ch.js const x = { grey: {} } export { x }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/requireTwoPropertyAccesses.ts
TypeScript
// @declaration // @outdir: out // @checkjs: true // @allowjs: true // @filename: mod.js module.exports = { x: { y: "value" } } // @filename: requireTwoPropertyAccesses.js const value = require("./mod").x.y console.log(value)
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/restElementMustBeLast.ts
TypeScript
var [...a, x] = [1, 2, 3]; // Error, rest must be last element [...a, x] = [1, 2, 3]; // Error, rest must be last element
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/restElementWithAssignmentPattern1.ts
TypeScript
//@target: ES6 var a: string, b: number; [...[a, b = 0]] = ["", 1];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/restElementWithAssignmentPattern2.ts
TypeScript
//@target: ES6 var a: string, b: number; [...{ 0: a = "", b }] = ["", 1];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/restElementWithAssignmentPattern3.ts
TypeScript
var a: string, b: number; var tuple: [string, number] = ["", 1]; [...[a, b = 0]] = tuple;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/restElementWithAssignmentPattern4.ts
TypeScript
var a: string, b: number; var tuple: [string, number] = ["", 1]; [...{ 0: a = "", b }] = tuple;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/restElementWithAssignmentPattern5.ts
TypeScript
var s: string, s2: string; [...[s, s2]] = ["", ""];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/restElementWithBindingPattern.ts
TypeScript
var [...[a, b]] = [0, 1];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/restElementWithBindingPattern2.ts
TypeScript
var [...{0: a, b }] = [0, 1];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/restElementWithNullInitializer.ts
TypeScript
function foo1([...r] = null) { } function foo2([...r] = undefined) { } function foo3([...r] = {}) { } function foo4([...r] = []) { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/restParameterInDownlevelGenerator.ts
TypeScript
// @target: es5 // @lib: es2015 // @downlevelIteration: true // @noEmitHelpers: true // https://github.com/Microsoft/TypeScript/issues/30653 function * mergeStringLists(...strings: string[]) { for (var str of strings); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/restPropertyWithBindingPattern.ts
TypeScript
({...{}} = {}); ({...({})} = {}); ({...[]} = {}); ({...([])} = {});
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/restTuplesFromContextualTypes.ts
TypeScript
// @strict: true // @declaration: true declare const t1: [number, boolean, string]; (function (a, b, c){})(...t1); (function (...x){})(...t1); (function (a, ...x){})(...t1); (function (a, b, ...x){})(...t1); (function (a, b, c, ...x){})(...t1); declare function f1(cb: (...args: typeof t1) => void): void; f1((a, b, c) => {}) f1((...x) => {}) f1((a, ...x) => {}) f1((a, b, ...x) => {}) f1((a, b, c, ...x) => {}) declare const t2: [number, boolean, ...string[]]; (function (a, b, c){})(...t2); (function (...x){})(...t2); (function (a, ...x){})(...t2); (function (a, b, ...x){})(...t2); (function (a, b, c, ...x){})(...t2); declare function f2(cb: (...args: typeof t2) => void): void; f2((a, b, c) => {}) f2((...x) => {}) f2((a, ...x) => {}) f2((a, b, ...x) => {}) f2((a, b, c, ...x) => {}) declare const t3: [boolean, ...string[]]; (function (a, b, c){})(1, ...t3); (function (...x){})(1, ...t3); (function (a, ...x){})(1, ...t3); (function (a, b, ...x){})(1, ...t3); (function (a, b, c, ...x){})(1, ...t3); declare function f3(cb: (x: number, ...args: typeof t3) => void): void; f3((a, b, c) => {}) f3((...x) => {}) f3((a, ...x) => {}) f3((a, b, ...x) => {}) f3((a, b, c, ...x) => {}) function f4<T extends any[]>(t: T) { (function(...x){})(...t); (function(a, ...x){})(1, ...t); (function(a, ...x){})(1, 2, ...t); function f(cb: (x: number, ...args: T) => void) {} f((...x) => {}); f((a, ...x) => {}); f((a, b, ...x) => {}); } declare function f5<T extends any[], U>(f: (...args: T) => U): (...args: T) => U; let g0 = f5(() => "hello"); let g1 = f5((x, y) => 42); let g2 = f5((x: number, y) => 42); let g3 = f5((x: number, y: number) => x + y); let g4 = f5((...args) => true); declare function pipe<A extends any[], B, C>(f: (...args: A) => B, g: (x: B) => C): (...args: A) => C; let g5 = pipe(() => true, b => 42); let g6 = pipe(x => "hello", s => s.length); let g7 = pipe((x, y) => 42, x => "" + x); let g8 = pipe((x: number, y: string) => 42, x => "" + x); // Repro from #25288 declare var tuple: [number, string]; (function foo(a, b){}(...tuple)); // Repro from #25289 declare function take(cb: (a: number, b: string) => void): void; (function foo(...rest){}(1, '')); take(function(...rest){}); // Repro from #29833 type ArgsUnion = [number, string] | [number, Error]; type TupleUnionFunc = (...params: ArgsUnion) => number; const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { return num; }; const funcUnionTupleRest: TupleUnionFunc = (...params) => { const [num, strOrErr] = params; return num; };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/returnStatements.ts
TypeScript
// all the following should be valid function fn1(): number { return 1; } function fn2(): string { return ''; } function fn3(): void { return undefined; } function fn4(): void { return; } function fn5(): boolean { return true; } function fn6(): Date { return new Date(12); } function fn7(): any { return null; } function fn8(): any { return; } // OK, eq. to 'return undefined' interface I { id: number } class C implements I { id: number; dispose() {} } class D extends C { name: string; } function fn10(): I { return { id: 12 }; } function fn11(): I { return new C(); } function fn12(): C { return new D(); } function fn13(): C { return null; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/returnTagTypeGuard.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @lib: esnext // @Filename: bug25127.js class Entry { constructor() { this.c = 1 } /** * @param {any} x * @return {this is Entry} */ isInit(x) { return true } } class Group { constructor() { this.d = 'no' } /** * @param {any} x * @return {false} */ isInit(x) { return false } } /** @param {Entry | Group} chunk */ function f(chunk) { let x = chunk.isInit(chunk) ? chunk.c : chunk.d return x } /** * @param {any} value * @return {value is boolean} */ function isBoolean(value) { return typeof value === "boolean"; } /** @param {boolean | number} val */ function foo(val) { if (isBoolean(val)) { val; } } /** * @callback Cb * @param {unknown} x * @return {x is number} */ /** @type {Cb} */ function isNumber(x) { return typeof x === "number" } /** @param {unknown} x */ function g(x) { if (isNumber(x)) { x * 2; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerAdditiveExpression1.ts
TypeScript
m.index+1+m[0].length;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerClass2.ts
TypeScript
export class LoggerAdapter implements ILogger { constructor (public logger: ILogger) { this._information = this.logger.information(); } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerES3NumericLiteral1.ts
TypeScript
0
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerES3NumericLiteral5.ts
TypeScript
1e0
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerES3NumericLiteral7.ts
TypeScript
1e+0
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerEnum1.ts
TypeScript
export enum CodeGenTarget { ES3 = 0, ES5 = 1, }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerImportDeclaration1.ts
TypeScript
import TypeScript = TypeScriptServices.TypeScript;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerNonAsciiHorizontalWhitespace.ts
TypeScript
//// [scannerNonAsciiHorizontalWhitespace.ts] "  function f() {}" //// [scannerNonAsciiHorizontalWhitespace.js] "  function f() {}"
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerNumericLiteral1.ts
TypeScript
// @target: ES5 0
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerNumericLiteral5.ts
TypeScript
// @target: ES5 1e0
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerNumericLiteral7.ts
TypeScript
// @target: ES5 1e+0
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerS7.2_A1.5_T2.ts
TypeScript
// Copyright 2009 the Sputnik authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /** * NO-BREAK SPACE (U+00A0) between any two tokens is allowed * * @path ch07/7.2/S7.2_A1.5_T2.js * @description Insert real NO-BREAK SPACE between tokens of var x=1 */ //CHECK#1 eval("\u00A0var x\u00A0= 1\u00A0"); if (x !== 1) { $ERROR('#1: eval("\\u00A0var x\\u00A0= 1\\u00A0"); x === 1. Actual: ' + (x)); } //CHECK#2  var x = 1 ; if (x !== 1) { $ERROR('#2:  var x = 1 ; x === 1. Actual: ' + (x)); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerS7.3_A1.1_T2.ts
TypeScript
// Copyright 2009 the Sputnik authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /** * LINE FEED (U+000A) may occur between any two tokens * * @path ch07/7.3/S7.3_A1.1_T2.js * @description Insert real LINE FEED between tokens of var x=1 */ //CHECK#1 var x = 1; if (x !== 1) { $ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x)); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannerS7.6_A4.2_T1.ts
TypeScript
// Copyright 2009 the Sputnik authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /** * Correct interpretation of RUSSIAN ALPHABET * * @path ch07/7.6/S7.6_A4.2_T1.js * @description Check RUSSIAN CAPITAL ALPHABET */ //CHECK#А-Я var \u0410 = 1; if (А !== 1) { $ERROR('#А'); } var \u0411 = 1; if (Б !== 1) { $ERROR('#Б'); } var \u0412 = 1; if (В !== 1) { $ERROR('#В'); } var \u0413 = 1; if (Г !== 1) { $ERROR('#Г'); } var \u0414 = 1; if (Д !== 1) { $ERROR('#Д'); } var \u0415 = 1; if (Е !== 1) { $ERROR('#Е'); } var \u0416 = 1; if (Ж !== 1) { $ERROR('#Ж'); } var \u0417 = 1; if (З !== 1) { $ERROR('#З'); } var \u0418 = 1; if (И !== 1) { $ERROR('#И'); } var \u0419 = 1; if (Й !== 1) { $ERROR('#Й'); } var \u041A = 1; if (К !== 1) { $ERROR('#К'); } var \u041B = 1; if (Л !== 1) { $ERROR('#Л'); } var \u041C = 1; if (М !== 1) { $ERROR('#М'); } var \u041D = 1; if (Н !== 1) { $ERROR('#Н'); } var \u041E = 1; if (О !== 1) { $ERROR('#О'); } var \u041F = 1; if (П !== 1) { $ERROR('#П'); } var \u0420 = 1; if (Р !== 1) { $ERROR('#Р'); } var \u0421 = 1; if (С !== 1) { $ERROR('#С'); } var \u0422 = 1; if (Т !== 1) { $ERROR('#Т'); } var \u0423 = 1; if (У !== 1) { $ERROR('#У'); } var \u0424 = 1; if (Ф !== 1) { $ERROR('#Ф'); } var \u0425 = 1; if (Х !== 1) { $ERROR('#Х'); } var \u0426 = 1; if (Ц !== 1) { $ERROR('#Ц'); } var \u0427 = 1; if (Ч !== 1) { $ERROR('#Ч'); } var \u0428 = 1; if (Ш !== 1) { $ERROR('#Ш'); } var \u0429 = 1; if (Щ !== 1) { $ERROR('#Щ'); } var \u042A = 1; if (Ъ !== 1) { $ERROR('#Ъ'); } var \u042B = 1; if (Ы !== 1) { $ERROR('#Ы'); } var \u042C = 1; if (Ь !== 1) { $ERROR('#Ь'); } var \u042D = 1; if (Э !== 1) { $ERROR('#Э'); } var \u042E = 1; if (Ю !== 1) { $ERROR('#Ю'); } var \u042F = 1; if (Я !== 1) { $ERROR('#Я'); } var \u0401 = 1; if (Ё !== 1) { $ERROR('#Ё'); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scannertest1.ts
TypeScript
///<reference path='References.ts' /> class CharacterInfo { public static isDecimalDigit(c: number): boolean { return c >= CharacterCodes._0 && c <= CharacterCodes._9; } public static isHexDigit(c: number): boolean { return isDecimalDigit(c) || (c >= CharacterCodes.A && c <= CharacterCodes.F) || (c >= CharacterCodes.a && c <= CharacterCodes.f); } public static hexValue(c: number): number { Debug.assert(isHexDigit(c)); return isDecimalDigit(c) ? (c - CharacterCodes._0) : (c >= CharacterCodes.A && c <= CharacterCodes.F) ? c - CharacterCodes.A + 10 : c - CharacterCodes.a + 10; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scopeResolutionIdentifiers.ts
TypeScript
// EveryType used in a nested scope of a different EveryType with the same name, type of the identifier is the one defined in the inner scope var s: string; module M1 { export var s: number; var n = s; var n: number; } module M2 { var s: number; var n = s; var n: number; } function fn() { var s: boolean; var n = s; var n: boolean; } class C { s: Date; n = this.s; x() { var p = this.n; var p: Date; } } module M3 { var s: any; module M4 { var n = s; var n: any; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/scopedPackagesClassic.ts
TypeScript
// @noImplicitReferences: true // @traceResolution: true // @typeRoots: types // @moduleResolution: classic // @filename: /node_modules/@types/see__saw/index.d.ts export const x = 0; // @filename: /a.ts import { x } from "@see/saw";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/seeTag1.ts
TypeScript
// @declaration: true interface Foo { foo: string } namespace NS { export interface Bar { baz: Foo } } /** @see {Foo} foooo*/ const a = "" /** @see {NS.Bar} ns.bar*/ const b = "" /** @see {b} b */ const c = ""
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/seeTag2.ts
TypeScript
// @declaration: true /** @see {} empty*/ const a = "" /** @see {aaaaaa} unknown name*/ const b = "" /** @see {?????} invalid */ const c = "" /** @see c without brace */ const d = "" /** @see ?????? wowwwwww*/ const e = "" /** @see {}*/ const f = "" /** @see */ const g = ""
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/seeTag3.ts
TypeScript
// @outdir: out/ // @checkJs: true // @filename: seeTag3.js /** @see [The typescript web site](https://typescriptlang.org) */ function theWholeThing() { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/seeTag4.ts
TypeScript
// @checkJs: true // @allowJs: true // @outdir: out/ // @filename: seeTag4.js /** * @typedef {any} A */ /** * @see {@link A} * @see {@linkcode A} * @see {@linkplain A} */ let foo;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/shadowedInternalModule.ts
TypeScript
// all errors imported modules conflict with local variables module A { export var Point = { x: 0, y: 0 } export interface Point { x: number; y: number; } } module B { var A = { x: 0, y: 0 }; import Point = A; } module X { export module Y { export interface Point{ x: number; y: number } } export class Y { name: string; } } module Z { import Y = X.Y; var Y = 12; } // module a { export type A = number; } module b { export import A = a.A; export module A {} } module c { import any = b.A; } // module q { export const Q = {}; } module r { export import Q = q.Q; export type Q = number; } module s { import Q = r.Q; const Q = 0; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.ts
TypeScript
// @declaration: true function foo(x: 'a'); function foo(x: number) { } class C { foo(x: 'a'); foo(x: number); foo(x: any) { } } class C2<T> { foo(x: 'a'); foo(x: T); foo(x: any) { } } class C3<T extends String> { foo(x: 'a'); foo(x: T); foo(x: any) { } } interface I { (x: 'a'); (x: number); foo(x: 'a'); foo(x: number); } interface I2<T> { (x: 'a'); (x: T); foo(x: 'a'); foo(x: T); } interface I3<T extends String> { (x: 'a'); (x: T); foo(x: 'a'); foo(x: T); } var a: { (x: 'a'); (x: number); foo(x: 'a'); foo(x: number); } var a2: { (x: 'a'); <T>(x: T); foo(x: 'a'); foo<T>(x: T); } var a3: { (x: 'a'); <T>(x: T); foo(x: 'a'); foo<T extends String>(x: T); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/specializedSignatureIsSubtypeOfNonSpecializedSignature.ts
TypeScript
// Specialized signatures must be a subtype of a non-specialized signature // All the below should not be errors function foo(x: 'a'); function foo(x: string); function foo(x: any) { } class C { foo(x: 'a'); foo(x: string); foo(x: any) { } } class C2<T> { foo(x: 'a'); foo(x: string); foo(x: T); foo(x: any) { } } class C3<T extends String> { foo(x: 'a'); foo(x: string); foo(x: T); foo(x: any) { } } interface I { (x: 'a'); (x: number); (x: string); foo(x: 'a'); foo(x: string); foo(x: number); } interface I2<T> { (x: 'a'); (x: T); (x: string); foo(x: 'a'); foo(x: string); foo(x: T); } interface I3<T extends String> { (x: 'a'); (x: string); (x: T); foo(x: 'a'); foo(x: string); foo(x: T); } var a: { (x: string); (x: 'a'); (x: number); foo(x: string); foo(x: 'a'); foo(x: number); } var a2: { (x: 'a'); (x: string); <T>(x: T); foo(x: string); foo(x: 'a'); foo<T>(x: T); } var a3: { (x: 'a'); <T>(x: T); (x: string); foo(x: string); foo(x: 'a'); foo<T extends String>(x: T); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/specializedSignatureWithOptional.ts
TypeScript
declare function f(x?: "hi"): void; declare function f(x?: string): void;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spellingUncheckedJS.ts
TypeScript
// @noEmit: true // @allowJs: true // @filename: spellingUncheckedJS.js export var inModule = 1 inmodule.toFixed() function f() { var locals = 2 + true locale.toFixed() // @ts-expect-error localf.toExponential() // @ts-expect-error "this is fine" } class Classe { non = 'oui' methode() { // no error on 'this' references return this.none } } class Derivee extends Classe { methode() { // no error on 'super' references return super.none } } var object = { spaaace: 3 } object.spaaaace // error on read object.spaace = 12 // error on write object.fresh = 12 // OK other.puuuce // OK, from another file new Date().getGMTDate() // OK, from another file // No suggestions for globals from other files const atoc = setIntegral(() => console.log('ok'), 500) AudioBuffin // etc Jimmy Jon // @filename: other.js var Jimmy = 1 var John = 2 Jon // error, it's from the same file var other = { puuce: 4 }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadContextualTypedBindingPattern.ts
TypeScript
// #18308 interface Person { naam: string, age: number } declare const bob: Person declare const alice: Person // [ts] Initializer provides no value for this binding element and the binding element has no default value. const { naam, age } = {...bob, ...alice}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadDuplicate.ts
TypeScript
// @strict: true // @declaration: true // Repro from #44438 declare let a: { a: string }; declare let b: { a?: string }; declare let c: { a: string | undefined }; declare let d: { a?: string | undefined }; declare let t: boolean; let a1 = { a: 123, ...a }; // string (Error) let b1 = { a: 123, ...b }; // string | number let c1 = { a: 123, ...c }; // string | undefined (Error) let d1 = { a: 123, ...d }; // string | number let a2 = { a: 123, ...(t ? a : {}) }; // string | number let b2 = { a: 123, ...(t ? b : {}) }; // string | number let c2 = { a: 123, ...(t ? c : {}) }; // string | number let d2 = { a: 123, ...(t ? d : {}) }; // string | number
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadDuplicateExact.ts
TypeScript
// @strict: true // @exactOptionalPropertyTypes: true // @declaration: true // Repro from #44438 declare let a: { a: string }; declare let b: { a?: string }; declare let c: { a: string | undefined }; declare let d: { a?: string | undefined }; declare let t: boolean; let a1 = { a: 123, ...a }; // string (Error) let b1 = { a: 123, ...b }; // string | number let c1 = { a: 123, ...c }; // string | undefined (Error) let d1 = { a: 123, ...d }; // string | number | undefined let a2 = { a: 123, ...(t ? a : {}) }; // string | number let b2 = { a: 123, ...(t ? b : {}) }; // string | number let c2 = { a: 123, ...(t ? c : {}) }; // string | number | undefined let d2 = { a: 123, ...(t ? d : {}) }; // string | number | undefined
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadExcessProperty.ts
TypeScript
type A = { a: string, b: string }; const extra1 = { a: "a", b: "b", extra: "extra" }; const a1: A = { ...extra1 }; // spread should not give excess property errors
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadMethods.ts
TypeScript
// @target: esnext // @useDefineForClassFields: false class K { p = 12; m() { } get g() { return 0; } } interface I { p: number; m(): void; readonly g: number; } let k = new K() let sk = { ...k }; let ssk = { ...k, ...k }; sk.p; sk.m(); // error sk.g; // error ssk.p; ssk.m(); // error ssk.g; // error let i: I = { p: 12, m() { }, get g() { return 0; } }; let si = { ...i }; let ssi = { ...i, ...i }; si.p; si.m(); // ok si.g; // ok ssi.p; ssi.m(); // ok ssi.g; // ok let o = { p: 12, m() { }, get g() { return 0; } }; let so = { ...o }; let sso = { ...o, ...o }; so.p; so.m(); // ok so.g; // ok sso.p; sso.m(); // ok sso.g; // ok
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadNonObject1.ts
TypeScript
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/45493 type S = `${number}`; const b = { c: (["4"] as S[]).map(function (s) { const a = { ...s, y: 6 }; }), };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadNonPrimitive.ts
TypeScript
declare let o: object; const x: { a: number, b: number } = { a: 1, ...o, b: 2 };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadObjectOrFalsy.ts
TypeScript
// @strict: true // @declaration: true function f1<T>(a: T & undefined) { return { ...a }; // Error } function f2<T>(a: T | T & undefined) { return { ...a }; } function f3<T extends undefined>(a: T) { return { ...a }; // Error } function f4<T extends undefined>(a: object | T) { return { ...a }; } function f5<S, T extends undefined>(a: S | T) { return { ...a }; } function f6<T extends object | undefined>(a: T) { return { ...a }; } // Repro from #46976 function g1<T extends {}, A extends { z: (T | undefined) & T }>(a: A) { const { z } = a; return { ...z }; } // Repro from #47028 interface DatafulFoo<T> { data: T; } class Foo<T extends string> { data: T | undefined; bar() { if (this.hasData()) { this.data.toLocaleLowerCase(); } } hasData(): this is DatafulFoo<T> { return true; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadOverwritesProperty.ts
TypeScript
// without strict null checks, none of these should be an error declare var ab: { a: number, b: number }; declare var abq: { a: number, b?: number }; var unused1 = { b: 1, ...ab } var unused2 = { ...ab, ...ab } var unused3 = { b: 1, ...abq } function g(obj: { x: number | undefined }) { return { x: 1, ...obj }; } function h(obj: { x: number }) { return { x: 1, ...obj }; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadOverwritesPropertyStrict.ts
TypeScript
// @strict: true declare var ab: { a: number, b: number }; declare var abq: { a: number, b?: number }; var unused1 = { b: 1, ...ab } // error var unused2 = { ...ab, ...ab } // ok, overwritten error doesn't apply to spreads var unused3 = { b: 1, ...abq } // ok, abq might have b: undefined var unused4 = { ...ab, b: 1 } // ok, we don't care that b in ab is overwritten var unused5 = { ...abq, b: 1 } // ok function g(obj: { x: number | undefined }) { return { x: 1, ...obj }; // ok, obj might have x: undefined } function f(obj: { x: number } | undefined) { return { x: 1, ...obj }; // ok, obj might be undefined } function h(obj: { x: number } | { x: string }) { return { x: 1, ...obj } // error } function i(b: boolean, t: { command: string, ok: string }) { return { command: "hi", ...(b ? t : {}) } // ok } function j() { return { ...{ command: "hi" } , ...{ command: "bye" } } // ok } function k(t: { command: string, ok: string }) { return { command: "hi", ...{ spoiler: true }, spoiler2: true, ...t } // error } function l(anyrequired: { a: any }) { return { a: 'zzz', ...anyrequired } // error } function m(anyoptional: { a?: any }) { return { a: 'zzz', ...anyoptional } // ok }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadTypeVariable.ts
TypeScript
function f1<T extends number>(arg: T) { return { ...arg }; } function f2<T extends string[]>(arg: T) { return { ...arg } } function f3<T extends number | string[]>(arg: T) { return { ...arg } } function f4<T extends number | { [key: string]: any }>(arg: T) { return { ...arg } } function f5<T extends string[] | { [key: string]: any }>(arg: T) { return { ...arg } } function f6<T>(arg: T) { return { ...arg } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadUnion.ts
TypeScript
var union: { a: number } | { b: string }; var o3: { a: number } | { b: string }; var o3 = { ...union }; var o4: { a: boolean } | { b: string , a: boolean}; var o4 = { ...union, a: false }; var o5: { a: number } | { b: string } | { a: number, b: string }; var o5 = { ...union, ...union };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadUnion2.ts
TypeScript
// @strictNullChecks: true declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; var o1: {} | { a: number }; var o1 = { ...undefinedUnion }; var o2: {} | { b: number }; var o2 = { ...nullUnion }; var o3: {} | { a: number } | { b: number } | { a: number, b: number }; var o3 = { ...undefinedUnion, ...nullUnion }; var o3 = { ...nullUnion, ...undefinedUnion }; var o4: {} | { a: number }; var o4 = { ...undefinedUnion, ...undefinedUnion }; var o5: {} | { b: number }; var o5 = { ...nullUnion, ...nullUnion };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University