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/typeParameterUsedAsConstraint.ts
TypeScript
class C<T, U extends T> { } class C2<T extends U, U> { } class C3<T extends Date, U extends T> { } class C4<T extends U, U extends Date> { } class C5<T extends U, U extends V, V> { } class C6<T, U extends T, V extends U> { } interface I<T, U extends T> { } interface I2<T extends U, U> { } interface I3<T extends Date, U extends T> { } interface I4<T extends U, U extends Date> { } interface I5<T extends U, U extends V, V> { } interface I6<T, U extends T, V extends U> { } function f<T, U extends T>() { } function f2<T extends U, U>() { } function f3<T extends Date, U extends T>() { } function f4<T extends U, U extends Date>() { } function f5<T extends U, U extends V, V>() { } function f6<T, U extends T, V extends U>() { } var e = <T, U extends T>() => { } var e2 = <T extends U, U>() => { } var e3 = <T extends Date, U extends T>() => { } var e4 = <T extends U, U extends Date>() => { } var e5 = <T extends U, U extends V, V>() => { } var e6 = <T, U extends T, V extends U>() => { } var a: { <T, U extends T>(): void } var a2: { <T extends U, U>(): void } var a3: { <T extends Date, U extends T>(): void } var a4: { <T extends U, U extends Date>(): void } var a5: { <T extends U, U extends V, V>(): void } var a6: { <T, U extends T, V extends U>(): void }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeParameterUsedAsTypeParameterConstraint.ts
TypeScript
// Type parameters are in scope in their own and other type parameter lists function foo<T, U extends T>(x: T, y: U): T { x = y; return y; } function foo2<U extends T, T>(x: T, y: U): T { x = y; return y; } var f = function <T, U extends T>(x: T, y: U): T { x = y; return y; } var f2 = function <U extends T, T>(x: T, y: U): T { x = y; return y; } var f3 = <T, U extends T>(x: T, y: U): T => { x = y; return y; } var f4 = <U extends T, T>(x: T, y: U): T => { x = y; return y; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeParameterUsedAsTypeParameterConstraint2.ts
TypeScript
// Type parameters are in scope in their own and other type parameter lists // Nested local functions function foo<T, U extends T>(x: T, y: U) { function bar<V extends T, W extends U>() { function baz<X extends W, Y extends V>(a: X, b: Y): T { x = y; return y; } } } function foo2<U extends T, T>(x: T, y: U) { function bar<V extends T, W extends U>() { function baz<X extends W, Y extends V>(a: X, b: Y): T { x = y; return y; } } } var f = function <T, U extends T>(x: T, y: U) { function bar<V extends T, W extends U>() { var g = function <X extends W, Y extends V>(a: X, b: Y): T { x = y; return y; } } } var f2 = function <U extends T, T>(x: T, y: U) { function bar<V extends T, W extends U>() { var g = function baz<X extends W, Y extends V>(a: X, b: Y): T { x = y; return y; } } } var f3 = <T, U extends T>(x: T, y: U) => { function bar<V extends T, W extends U>() { var g = <X extends W, Y extends V>(a: X, b: Y): T => { x = y; return y; } } } var f4 = <U extends T, T>(x: T, y: U) => { function bar<V extends T, W extends U>() { var g = <X extends W, Y extends V>(a: X, b: Y): T => { x = y; return y; } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeParameterUsedAsTypeParameterConstraint3.ts
TypeScript
// Type parameters are in scope in their own and other type parameter lists // Object types //class C<T, U extends T, V extends U> { // x: T; // y: U; // z: V; // foo<W extends V>(x: W): T { // var r: T; // return x; // } //} //class C2<V extends U, T, U extends T> { // x: T; // y: U; // z: V; // foo<W extends V>(x: W): T { // var r: T; // return x; // } //} interface I<T, U, V> { x: T; y: U; z: V; foo<W extends V>(x: W): T; } interface I2<V, T, U> { x: T; y: U; z: V; foo<W extends V>(x: W): T; } //interface I < T, U extends T, V extends U > { // x: T; // y: U; // z: V; // foo<W extends V>(x: W): T; //} //interface I2<V extends U, T, U extends T> { // x: T; // y: U; // z: V; // foo<W extends V>(x: W): T; //}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeParameterUsedAsTypeParameterConstraint4.ts
TypeScript
// Type parameters are in scope in their own and other type parameter lists // Some negative cases class C<T, U extends T, V extends U> { z: W; // error foo<W extends V>(x: W): T { var r: T; return x; } } interface I<T, U extends T, V extends U> { x: T; y: U; z: W; // error foo<W extends V>(x: W): T; } function foo<T, U extends T>(x: T, y: U): V { // error function bar<V extends T, W extends U>(): X { // error function baz<X extends W, Y extends V>(a: X, b: Y): T { x = y; return y; } } } function foo2<U extends T, T>(x: T, y: U): W { // error function bar<V extends T, W extends U>(): Y { // error function baz<X extends W, Y extends V>(a: X, b: Y): T { x = y; return y; } } } var f3 = <T, U extends T>(x: T, y: U) => { function bar<V extends T, W extends U>(r: X, s: Y) { // error var g = <X extends W, Y extends V>(a: X, b: Y): T => { x = y; return y; } } } var f4 = <U extends T, T>(x: V, y: X) => { // error function bar<V extends T, W extends U>() { var g = <X extends W, Y extends V>(a: X, b: Y): T => { x = y; return y; } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeParametersAreIdenticalToThemselves.ts
TypeScript
// type parameters from the same declaration are identical to themself function foo1<T>(x: T); function foo1<T>(x: T); // no error, different declaration for each T function foo1<T>(x: T) { } function foo2<T, U>(x: T); function foo2<T, U>(x: T); // no error, different declaration for each T function foo2<T, U>(x: T) { } function foo3<T, U>(x: T, y: U) { function inner(x: T); function inner(x: T); // error, same T function inner(x: T) { } function inner2(x: T); function inner2<T>(x: T); // no error, different T function inner2(x: any) { } } class C<T> { foo1(x: T); foo1(x: T); // error, same T foo1(x: T) { } foo2<U>(a: T, x: U); foo2<U>(a: T, x: U); // no error, different declaration for each U foo2<U>(a: T, x: U) { } foo3<T>(x: T); foo3<T>(x: T); // no error, different declaration for each T foo3<T>(x: T) { } foo4<T extends Date>(x: T); foo4<T extends Date>(x: T); // no error, different declaration for each T foo4<T extends Date>(x: T) { } } class C2<T extends Date> { foo1(x: T); foo1(x: T); // error, same T foo1(x: T) { } foo2<U>(a: T, x: U); foo2<U>(a: T, x: U); // no error, different declaration for each U foo2<U>(a: T, x: U) { } foo3<T>(x: T); foo3<T>(x: T); // no error, different declaration for each T foo3<T>(x: T) { } } interface I<T> { foo1(x: T); foo1(x: T); // error, same T foo2<U>(a: T, x: U); foo2<U>(a: T, x: U); // no error, different declaration for each U foo3<T>(x: T); foo3<T>(x: T); // no error, different declaration for each T foo4<T extends Date>(x: T); foo4<T extends Date>(x: T); // no error, different declaration for each T } interface I2<T extends Date> { foo1(x: T); foo1(x: T); // error, same T foo2<U>(a: T, x: U); foo2<U>(a: T, x: U); // no error, different declaration for each U foo3<T>(x: T); foo3<T>(x: T); // no error, different declaration for each T }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeParametersAvailableInNestedScope.ts
TypeScript
class C<T> { data: T; x = <U>(a: U) => { var y: T; return y; } foo() { function temp<U>(a: U) { var y: T; return y; } return temp(<T>null); } } var c = new C<number>(); c.data = c.x(null); c.data = c.foo();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeParametersAvailableInNestedScope2.ts
TypeScript
function foo<T, U>(x: T, y: U) { function bar<V>(z: V) { function baz<W>(a: W) { var c: T; var d: U; var e: V; } } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeParametersAvailableInNestedScope3.ts
TypeScript
// @declaration: true function foo<T>(v: T) { function a<T>(a: T) { return a; } function b(): T { return v; } function c<T>(v: T) { function a<T>(a: T) { return a; } function b(): T { return v; } return { a, b }; } return { a, b, c }; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typePredicateASI.ts
TypeScript
interface I { foo(callback: (a: any, b: any) => void): I is(): boolean; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeQuery.ts
TypeScript
// @Filename: /a.ts export class A { } // @Filename: /b.ts import type { A } from './a'; let AConstructor: typeof A;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeQueryOnClass.ts
TypeScript
class C<T> { constructor(x: number); constructor(x: string); constructor(public x) { } static foo(x: number); static foo(x: {}); static foo(x) { } static bar(x) { } static sa = 1; static sb = () => 1; static get sc() { return 1; } static set sc(x) { } static get sd() { return 1; } baz(x): string { return ''; } ia = 1; ib = () => this.ia; get ic() { return 1; } set ic(x) { } get id() { return 1; } } var c: C<string>; // BUG 820454 var r1: typeof C; var r2: typeof c; class D<T> { constructor(public y?) { } x: T; foo() { } } var d: D<string>; var r3: typeof D; var r4: typeof d;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeQueryWithReservedWords.ts
TypeScript
class Controller { create() { } delete() { } var() { } } interface IScope { create: typeof Controller.prototype.create; delete: typeof Controller.prototype.delete; // Should not error var: typeof Controller.prototype.var; // Should not error }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeRelationships.ts
TypeScript
class C { self = this; c = new C(); foo() { return this; } f1() { this.c = this.self; this.self = this.c; // Error } f2() { var a: C[]; var a = [this, this.c]; // C[] since this is subtype of C var b: this[]; var b = [this, this.self, null, undefined]; } f3(b: boolean) { return b ? this.c : this.self; // Should be C } } class D extends C { self1 = this; self2 = this.self; self3 = this.foo(); d = new D(); bar() { this.self = this.self1; this.self = this.self2; this.self = this.self3; this.self1 = this.self; this.self2 = this.self; this.self3 = this.self; this.d = this.self; this.d = this.c; // Error this.self = this.d; // Error this.c = this.d; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_asConstArrays.ts
TypeScript
// @strict: true // @noEmit: true // with readonly array const arr1 = [1, 2, 3] as const satisfies readonly unknown[] // with mutable array const arr2 = [1, 2, 3] as const satisfies unknown[]
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_contextualTyping1.ts
TypeScript
type Predicates = { [s: string]: (n: number) => boolean }; const p = { isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1 } satisfies Predicates;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_contextualTyping2.ts
TypeScript
// @strict: true let obj: { f(s: string): void } & Record<string, unknown> = { f(s) { }, // "incorrect" implicit any on 's' g(s) { } } satisfies { g(s: string): void } & Record<string, unknown>; // This needs to not crash (outer node is not expression) ({ f(x) { } }) satisfies { f(s: string): void };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_contextualTyping3.ts
TypeScript
// @strict: true // @noEmit: true // see https://github.com/microsoft/TypeScript/issues/53920#issuecomment-1516616255 const obj = { foo: (param = "default") => param, } satisfies { [key: string]: (...params: any) => any; }; const obj2 = { foo: (param = "default") => param, } satisfies { [key: string]: Function; }; type StringOrNumberFunc = (x: string | number) => any; const fn = ((x = "ok") => null) satisfies StringOrNumberFunc; fn(); fn(32);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_ensureInterfaceImpl.ts
TypeScript
type Movable = { move(distance: number): void; }; const car = { start() { }, move(d) { // d should be number }, stop() { } } satisfies Movable & Record<string, unknown>;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.ts
TypeScript
// @allowJs: true // @filename: /src/a.js // @outFile: /lib/a.js var v = undefined satisfies 1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_optionalMemberConformance.ts
TypeScript
type Point2d = { x: number, y: number }; // Undesirable behavior today with type annotation const a = { x: 10 } satisfies Partial<Point2d>; // Should OK console.log(a.x.toFixed()); // Should error let p = a.y;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propNameConstraining.ts
TypeScript
type Keys = 'a' | 'b' | 'c' | 'd'; const p = { a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys' } satisfies Partial<Record<Keys, unknown>>; // Should be OK -- retain info that a is number and b is string let a = p.a.toFixed(); let b = p.b.substring(1); // Should error even though 'd' is in 'Keys' let d = p.d;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyNameFulfillment.ts
TypeScript
type Keys = 'a' | 'b' | 'c' | 'd'; const p = { a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys' } satisfies Record<Keys, unknown>; // Should be OK -- retain info that a is number and b is string let a = p.a.toFixed(); let b = p.b.substring(1); // Should error even though 'd' is in 'Keys' let d = p.d;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance1.ts
TypeScript
// @noPropertyAccessFromIndexSignature: true, false type Facts = { [key: string]: boolean }; declare function checkTruths(x: Facts): void; declare function checkM(x: { m: boolean }): void; const x = { m: true }; // Should be OK checkTruths(x); // Should be OK checkM(x); // Should fail under --noPropertyAccessFromIndexSignature console.log(x.z); const m: boolean = x.m; // Should be 'm' type M = keyof typeof x; // Should be able to detect a failure here const x2 = { m: true, s: "false" } satisfies Facts;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance2.ts
TypeScript
// @noUncheckedIndexedAccess: true, false type Facts = { [key: string]: boolean }; declare function checkTruths(x: Facts): void; declare function checkM(x: { m: boolean }): void; const x = { m: true }; // Should be OK checkTruths(x); // Should be OK checkM(x); console.log(x.z); // Should be OK under --noUncheckedIndexedAccess const m: boolean = x.m; // Should be 'm' type M = keyof typeof x; // Should be able to detect a failure here const x2 = { m: true, s: "false" } satisfies Facts;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance3.ts
TypeScript
export type Color = { r: number, g: number, b: number }; // All of these should be Colors, but I only use some of them here. export const Palette = { white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 }, } satisfies Record<string, Color>;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeSatisfaction_vacuousIntersectionOfContextualTypes.ts
TypeScript
const a: "baz" = "foo" satisfies "foo" | "bar"; const b: { xyz: "baz" } = { xyz: "foo" } satisfies { xyz: "foo" | "bar" };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeTagCircularReferenceOnConstructorFunction.ts
TypeScript
// @allowJs: true // @noEmit: true // @checkJs: true // @Filename: bug27346.js /** * @type {MyClass} */ function MyClass() { } MyClass.prototype = {};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeTagModuleExports.ts
TypeScript
// @Filename: bug27327.js // @noEmit: true // @allowJs: true // @checkJs: true /** @type {string} */ module.exports = 0;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeTagNoErasure.ts
TypeScript
// @checkJs:true // @declaration: true // @outdir: out/ // @filename: typeTagNoErasure.js /** @template T @typedef {<T1 extends T>(data: T1) => T1} Test */ /** @type {Test<number>} */ const test = dibbity => dibbity test(1) // ok, T=1 test('hi') // error, T=number
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeTagOnFunctionReferencesGeneric.ts
TypeScript
// @checkJs: true // @declaration: true // @outDir: out/ // @filename: typeTagOnFunctionReferencesGeneric.js /** * @typedef {<T>(m : T) => T} IFn */ /**@type {IFn}*/ export function inJs(l) { return l; } inJs(1); // lints error. Why? /**@type {IFn}*/ const inJsArrow = (j) => { return j; } inJsArrow(2); // no error gets linted as expected
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeTagOnPropertyAssignment.ts
TypeScript
// @noEmit: true // @checkJs: true // @filename: typeTagOnPropertyAssignment.js const o = { /** * @type {"a"} */ a: "a", /** @type {() => 'b'} */ n: () => 'b' }; o.a o.n
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeTagPrototypeAssignment.ts
TypeScript
// @Filename: bug27327.js // @noEmit: true // @allowJs: true // @checkJs: true function C() { } /** @type {string} */ C.prototype = 12
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeTagWithGenericSignature.ts
TypeScript
// @checkJs: true // @allowJs: true // @noEmit: true // @strict: true // @Filename: bug25618.js /** @type {<T>(param?: T) => T | undefined} */ function typed(param) { return param; } var n = typed(1);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeValueMerge1.ts
TypeScript
// @noEmit: true // @Filename: other.ts export type A = string; function A() {} export { A }; export type B = string; var B = 10; export { B }; // @Filename: main.ts import { A, B } from "./other"; A(); export const C = B;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefCrossModule.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: commonjs.d.ts declare var module: { exports: any}; // @Filename: mod1.js /// <reference path="./commonjs.d.ts"/> /** @typedef {{ type: "a", x: 1 }} A */ /** @typedef {{ type: "b", y: 1 }} B */ /** @typedef {A | B} Both */ module.exports = C function C() { this.p = 1 } // @Filename: mod2.js /// <reference path="./commonjs.d.ts"/> /** @typedef {{ type: "a", x: 1 }} A */ /** @typedef {{ type: "b", y: 1 }} B */ /** @typedef {A | B} Both */ export function C() { this.p = 1 } // @Filename: mod3.js /// <reference path="./commonjs.d.ts"/> /** @typedef {{ type: "a", x: 1 }} A */ /** @typedef {{ type: "b", y: 1 }} B */ /** @typedef {A | B} Both */ exports.C = function() { this.p = 1 } // @Filename: use.js /** @type {import('./mod1').Both} */ var both1 = { type: 'a', x: 1 }; /** @type {import('./mod2').Both} */ var both2 = both1; /** @type {import('./mod3').Both} */ var both3 = both2;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefCrossModule2.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: mod1.js // error /** @typedef {number} Foo */ class Foo { } // should error /** @typedef {number} Bar */ exports.Bar = class { } /** @typedef {number} Baz */ module.exports = { Baz: class { } } // ok /** @typedef {number} Qux */ var Qux = 2; /** @typedef {number} Quid */ exports.Quid = 2; /** @typedef {number} Quack */ module.exports = { Quack: 2 } // @Filename: use.js var mod = require('./mod1.js'); /** @type {import("./mod1.js").Baz} */ var b; /** @type {mod.Baz} */ var bb; var bbb = new mod.Baz();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefCrossModule3.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: mod2.js /** @typedef {number} Foo */ const ns = {}; ns.Foo = class {} module.exports = ns;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefCrossModule4.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: mod3.js /** @typedef {number} Foo */ class Bar { } module.exports = { Foo: Bar };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefCrossModule5.ts
TypeScript
// @pretty: true // @noEmit: true // @allowJs: true // @checkJs: true // @Filename: mod1.js /** @typedef {number} Foo */ class Bar {} // @Filename: mod2.js class Foo { } // should error const Bar = 3;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefDuplicateTypeDeclaration.ts
TypeScript
// @allowJS: true // @checkJS: true // @noEmit: true // @Filename: typedefDuplicateTypeDeclaration.js /** * @typedef Name * @type {string} * @type {Oops} */
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefInnerNamepaths.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: bug25104.js class C { /** * @typedef {C~A} C~B * @typedef {object} C~A */ /** @param {C~A} o */ constructor(o) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefMultipleTypeParameters.ts
TypeScript
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: a.js /** * @template {{ a: number, b: string }} T,U A Comment * @template {{ c: boolean }} V uh ... are comments even supported?? * @template W * @template X That last one had no comment * @typedef {{ t: T, u: U, v: V, w: W, x: X }} Everything */ /** @type {Everything<{ a: number, b: 'hi', c: never }, undefined, { c: true, d: 1 }, number, string>} */ var tuvwx; /** @type {Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>} */ var wrong; /** @type {Everything<{ a: number }>} */ var insufficient; // @Filename: test.ts declare var actually: Everything<{ a: number }, undefined, { c: 1, d: 1 }, number, string>;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefOnSemicolonClassElement.ts
TypeScript
// @filename: typedefOnSemicolonClassElement.js // @checkJs: true // @outdir: dist // @declaration: true export class Preferences { /** @typedef {string} A */ ; /** @type {A} */ a = 'ok' }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefScope1.ts
TypeScript
// @strict: true // @declaration: true // @outdir: out/ // @checkJs: true // @filename: typedefScope1.js function B1() { /** @typedef {number} B */ /** @type {B} */ var ok1 = 0; } function B2() { /** @typedef {string} B */ /** @type {B} */ var ok2 = 'hi'; } /** @type {B} */ var notOK = 0;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefTagExtraneousProperty.ts
TypeScript
// @lib: es5 // @allowjs: true // @checkjs: true // @noemit: true // @Filename: typedefTagExtraneousProperty.js /** @typedef {Object.<string,string>} Mmap * @property {string} ignoreMe - should be ignored */ /** @type {Mmap} */ var y = { bye: "no" }; y y.ignoreMe = "ok but just because of the index signature" y['hi'] = "yes"
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefTagNested.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @strict: true // @Filename: a.js /** @typedef {Object} App * @property {string} name * @property {Object} icons * @property {string} icons.image32 * @property {string} icons.image64 */ var ex; /** @type {App} */ const app = { name: 'name', icons: { image32: 'x.png', image64: 'y.png', } } /** @typedef {Object} Opp * @property {string} name * @property {Object} oops * @property {string} horrible * @type {string} idea */ var intercessor = 1 /** @type {Opp} */ var mistake; /** @typedef {Object} Upp * @property {string} name * @property {Object} not * @property {string} nested */ /** @type {Upp} */ var sala = { name: 'uppsala', not: 0, nested: "ok" }; sala.name sala.not sala.nested
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefTagTypeResolution.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: github20832.js // #20832 /** @typedef {U} T - should be "error, can't find type named 'U' */ /** * @template U * @param {U} x * @return {T} */ function f(x) { return x; } /** @type T - should be fine, since T will be any */ const x = 3; /** * @callback Cb * @param {V} firstParam */ /** * @template V * @param {V} vvvvv */ function g(vvvvv) { } /** @type {Cb} */ const cb = x => {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typedefTagWrapping.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: mod1.js /** * @typedef {function(string): boolean} * Type1 */ /** * Tries to use a type whose name is on a different * line than the typedef tag. * @param {Type1} func The function to call. * @param {string} arg The argument to call it with. * @returns {boolean} The return. */ function callIt(func, arg) { return func(arg); } // @Filename: mod2.js /** * @typedef {{ * num: number, * str: string, * boo: boolean * }} Type2 */ /** * Makes use of a type with a multiline type expression. * @param {Type2} obj The object. * @returns {string|number} The return. */ function check(obj) { return obj.boo ? obj.num : obj.str; } // @Filename: mod3.js /** * A function whose signature is very long. * * @typedef {function(boolean, string, number): * (string|number)} StringOrNumber1 */ /** * Makes use of a function type with a long signature. * @param {StringOrNumber1} func The function. * @param {boolean} bool The condition. * @param {string} str The string. * @param {number} num The number. * @returns {string|number} The return. */ function use1(func, bool, str, num) { return func(bool, str, num) } // @Filename: mod4.js /** * A function whose signature is very long. * * @typedef {function(boolean, string, * number): * (string|number)} StringOrNumber2 */ /** * Makes use of a function type with a long signature. * @param {StringOrNumber2} func The function. * @param {boolean} bool The condition. * @param {string} str The string. * @param {number} num The number. * @returns {string|number} The return. */ function use2(func, bool, str, num) { return func(bool, str, num) } // @Filename: mod5.js /** * @typedef {{ * num: * number, * str: * string, * boo: * boolean * }} Type5 */ /** * Makes use of a type with a multiline type expression. * @param {Type5} obj The object. * @returns {string|number} The return. */ function check5(obj) { return obj.boo ? obj.num : obj.str; } // @Filename: mod6.js /** * @typedef {{ * foo: * *, * bar: * * * }} Type6 */ /** * Makes use of a type with a multiline type expression. * @param {Type6} obj The object. * @returns {*} The return. */ function check6(obj) { return obj.foo; } // @Filename: mod7.js /** Multiline type expressions in comments without leading * are not supported. @typedef {{ foo: *, bar: * }} Type7 */
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofANonExportedType.ts
TypeScript
var x = 1; export var r1: typeof x; var y = { foo: '' }; export var r2: typeof y; class C { foo: string; } export var c: C; var c2: C; export var r3: typeof C; export var r4: typeof c; export var r4b: typeof c2; interface I { foo: string; } export var i: I; var i2: I; export var r5: typeof i; export var r5: typeof i2; module M { export var foo = ''; export class C { foo: string; } } export var r6: typeof M; export var r7: typeof M.foo; import Z = M; export var r8: typeof Z; export var r9: typeof Z.foo; enum E { A } export var r10: typeof E; export var r11: typeof E.A; export var r12: typeof r12; function foo() { } module foo { export var y = 1; export class C { foo: string; } } export var r13: typeof foo;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofAnExportedType.ts
TypeScript
export var x = 1; export var r1: typeof x; export var y = { foo: '' }; export var r2: typeof y; export class C { foo: string; } export var c: C; var c2: C; export var r3: typeof C; export var r4: typeof c; export var r4b: typeof c2; export interface I { foo: string; } export var i: I; var i2: I; export var r5: typeof i; export var r5: typeof i2; export module M { export var foo = ''; export class C { foo: string; } } export var r6: typeof M; export var r7: typeof M.foo; export import Z = M; export var r8: typeof Z; export var r9: typeof Z.foo; export enum E { A } export var r10: typeof E; export var r11: typeof E.A; export var r12: typeof r12; export function foo() { } export module foo { export var y = 1; export class C { foo: string; } } export var r13: typeof foo;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofClass2.ts
TypeScript
class C { constructor(x: number); constructor(x: string); constructor(x) { } static foo(x: number); static foo(x: C); static foo(x) { } static bar(x) { } } class D extends C { static baz(x: number) { } foo() { } } var d: D; var r1: typeof D; var r2: typeof d;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofClassWithPrivates.ts
TypeScript
class C<T> { private a: number; private static b: number; x: T; static y: T; } var c: C<string>; var r: typeof C; var r2: typeof c;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofImportTypeOnlyExport.ts
TypeScript
// @declaration: true // @Filename: button.ts import {classMap} from './lit.js'; export const c = classMap(); // @Filename: lit.ts class ClassMapDirective {} export type {ClassMapDirective}; export const directive = <C>(class_: C) => () => ({ directive: class_, }); export const classMap = directive(ClassMapDirective);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofModuleWithoutExports.ts
TypeScript
module M { var x = 1; class C { foo: number; } } var r: typeof M;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofOperatorWithAnyOtherType.ts
TypeScript
// typeof operator on any type var ANY: any; var ANY1; var ANY2: any[] = ["", ""]; var obj: () => {} var obj1 = { x: "a", y: () => { }}; function foo(): any { var a; return a; } class A { public a: any; static foo() { var a; return a; } } module M { export var n: any; } var objA = new A(); // any type var var ResultIsString1 = typeof ANY1; var ResultIsString2 = typeof ANY2; var ResultIsString3 = typeof A; var ResultIsString4 = typeof M; var ResultIsString5 = typeof obj; var ResultIsString6 = typeof obj1; // any type literal var ResultIsString7 = typeof undefined; var ResultIsString8 = typeof null; var ResultIsString9 = typeof {}; // any type expressions var ResultIsString10 = typeof ANY2[0]; var ResultIsString11 = typeof objA.a; var ResultIsString12 = typeof obj1.x; var ResultIsString13 = typeof M.n; var ResultIsString14 = typeof foo(); var ResultIsString15 = typeof A.foo(); var ResultIsString16 = typeof (ANY + ANY1); var ResultIsString17 = typeof (null + undefined); var ResultIsString18 = typeof (null + null); var ResultIsString19 = typeof (undefined + undefined); // multiple typeof operators var ResultIsString20 = typeof typeof ANY; var ResultIsString21 = typeof typeof typeof (ANY + ANY1); // miss assignment operators typeof ANY; typeof ANY1; typeof ANY2[0]; typeof ANY, ANY1; typeof obj1; typeof obj1.x; typeof objA.a; typeof M.n; // use typeof in type query var z: any; var x: any[]; var r: () => any; z: typeof ANY; x: typeof ANY2; r: typeof foo; z: typeof objA.a; z: typeof A.foo; z: typeof M.n; z: typeof obj1.x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofOperatorWithBooleanType.ts
TypeScript
// @allowUnusedLabels: true // typeof operator on boolean type var BOOLEAN: boolean; function foo(): boolean { return true; } class A { public a: boolean; static foo() { return false; } } module M { export var n: boolean; } var objA = new A(); // boolean type var var ResultIsString1 = typeof BOOLEAN; // boolean type literal var ResultIsString2 = typeof true; var ResultIsString3 = typeof { x: true, y: false }; // boolean type expressions var ResultIsString4 = typeof objA.a; var ResultIsString5 = typeof M.n; var ResultIsString6 = typeof foo(); var ResultIsString7 = typeof A.foo(); // multiple typeof operator var ResultIsString8 = typeof typeof BOOLEAN; // miss assignment operators typeof true; typeof BOOLEAN; typeof foo(); typeof true, false; typeof objA.a; typeof M.n; // use typeof in type query var z: boolean; var x: boolean[]; var r: () => boolean; z: typeof BOOLEAN; r: typeof foo; var y = { a: true, b: false}; z: typeof y.a; z: typeof objA.a; z: typeof A.foo; z: typeof M.n;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofOperatorWithEnumType.ts
TypeScript
// @allowUnusedLabels: true // typeof operator on enum type enum ENUM { }; enum ENUM1 { A, B, "" }; // enum type var var ResultIsString1 = typeof ENUM; var ResultIsString2 = typeof ENUM1; // enum type expressions var ResultIsString3 = typeof ENUM1["A"]; var ResultIsString4 = typeof (ENUM[0] + ENUM1["B"]); // multiple typeof operators var ResultIsString5 = typeof typeof ENUM; var ResultIsString6 = typeof typeof typeof (ENUM[0] + ENUM1.B); // miss assignment operators typeof ENUM; typeof ENUM1; typeof ENUM1["B"]; typeof ENUM, ENUM1; // use typeof in type query enum z { }; z: typeof ENUM; z: typeof ENUM1;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofOperatorWithNumberType.ts
TypeScript
// @allowUnusedLabels: true // typeof operator on number type var NUMBER: number; var NUMBER1: number[] = [1, 2]; function foo(): number { return 1; } class A { public a: number; static foo() { return 1; } } module M { export var n: number; } var objA = new A(); // number type var var ResultIsString1 = typeof NUMBER; var ResultIsString2 = typeof NUMBER1; // number type literal var ResultIsString3 = typeof 1; var ResultIsString4 = typeof { x: 1, y: 2}; var ResultIsString5 = typeof { x: 1, y: (n: number) => { return n; } }; // number type expressions var ResultIsString6 = typeof objA.a; var ResultIsString7 = typeof M.n; var ResultIsString8 = typeof NUMBER1[0]; var ResultIsString9 = typeof foo(); var ResultIsString10 = typeof A.foo(); var ResultIsString11 = typeof (NUMBER + NUMBER); // multiple typeof operators var ResultIsString12 = typeof typeof NUMBER; var ResultIsString13 = typeof typeof typeof (NUMBER + NUMBER); // miss assignment operators typeof 1; typeof NUMBER; typeof NUMBER1; typeof foo(); typeof objA.a; typeof M.n; typeof objA.a, M.n; // use typeof in type query var z: number; var x: number[]; z: typeof NUMBER; x: typeof NUMBER1; r: typeof foo; var y = { a: 1, b: 2 }; z: typeof y.a; z: typeof objA.a; z: typeof A.foo; z: typeof M.n;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofOperatorWithStringType.ts
TypeScript
// typeof operator on string type var STRING: string; var STRING1: string[] = ["", "abc"]; function foo(): string { return "abc"; } class A { public a: string; static foo() { return ""; } } module M { export var n: string; } var objA = new A(); // string type var var ResultIsString1 = typeof STRING; var ResultIsString2 = typeof STRING1; // string type literal var ResultIsString3 = typeof ""; var ResultIsString4 = typeof { x: "", y: "" }; var ResultIsString5 = typeof { x: "", y: (s: string) => { return s; } }; // string type expressions var ResultIsString6 = typeof objA.a; var ResultIsString7 = typeof M.n; var ResultIsString8 = typeof STRING1[0]; var ResultIsString9 = typeof foo(); var ResultIsString10 = typeof A.foo(); var ResultIsString11 = typeof (STRING + STRING); var ResultIsString12 = typeof STRING.charAt(0); // multiple typeof operators var ResultIsString13 = typeof typeof STRING; var ResultIsString14 = typeof typeof typeof (STRING + STRING); // miss assignment operators typeof ""; typeof STRING; typeof STRING1; typeof foo(); typeof objA.a, M.n; // use typeof in type query var z: string; var x: string[]; var r: () => string; z: typeof STRING; x: typeof STRING1; r: typeof foo; var y = { a: "", b: "" }; z: typeof y.a; z: typeof objA.a; z: typeof A.foo; z: typeof M.n;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofThis.ts
TypeScript
// @noImplicitThis: true // @strict: true class Test { data = {}; constructor() { var copy: typeof this.data = {}; } } class Test1 { data = { foo: '' }; ['this'] = ''; constructor() { var copy: typeof this.data = { foo: '' }; var foo: typeof this.data.foo = ''; var self: typeof this = this; self.data; var str: typeof this.this = ''; } } function Test2() { let x: typeof this.no = 1; } function Test3(this: { no: number }) { let x: typeof this.no = 1; } function Test4(this: { no: number } | undefined) { let x: typeof this.no = 1; } class Test5 { no = 1; f = () => { // should not capture this. let x: typeof this.no = 1; } } namespace Test6 { export let f = () => { let x: typeof this.no = 1; } } module Test7 { export let f = () => { let x: typeof this.no = 1; } } const Test8 = () => { let x: typeof this.no = 1; } class Test9 { no = 0; this = 0; f() { if (this instanceof Test9D1) { const d1: typeof this = this; d1.f1(); } if (this instanceof Test9D2) { const d2: typeof this = this; d2.f2(); } } g() { if (this.no === 1) { const no: typeof this.no = this.no; } if (this.this === 1) { const no: typeof this.this = this.this; } } } class Test9D1 { f1() {} } class Test9D2 { f2() {} } class Test10 { a?: { b?: string } foo() { let a: typeof this.a = undefined as any; if (this.a) { let a: typeof this.a = undefined as any; // should narrow to { b?: string } let b: typeof this.a.b = undefined as any; if (this.a.b) { let b: typeof this.a.b = undefined as any; // should narrow to string } } } } class Test11 { this?: { x?: string }; foo() { const o = this; let bar: typeof o.this = {}; if (o.this && o.this.x) { let y: string = o.this.x; // should narrow to string } } } class Tests12 { test1() { // OK type Test = typeof this; } test2() { // OK for (;;) {} type Test = typeof this; } test3() { // expected no compile errors for (const dummy in []) {} type Test = typeof this; } test4() { // expected no compile errors for (const dummy of []) {} type Test = typeof this; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofThisWithImplicitThis.ts
TypeScript
// @noImplicitThis: false function Test1() { let x: typeof this.no = 1 }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typeofTypeParameter.ts
TypeScript
function f<T>(x: T): T { var a: typeof x; var y: typeof T; return a; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/types.asyncGenerators.es2018.1.ts
TypeScript
// @target: es2018 // @lib: esnext // @noEmit: true async function * inferReturnType1() { } async function * inferReturnType2() { yield; } async function * inferReturnType3() { yield 1; } async function * inferReturnType4() { yield Promise.resolve(1); } async function * inferReturnType5() { yield 1; yield Promise.resolve(2); } async function * inferReturnType6() { yield* [1, 2]; } async function * inferReturnType7() { yield* [Promise.resolve(1)]; } async function * inferReturnType8() { yield* (async function * () { yield 1; })(); } const assignability1: () => AsyncIterableIterator<number> = async function * () { yield 1; }; const assignability2: () => AsyncIterableIterator<number> = async function * () { yield Promise.resolve(1); }; const assignability3: () => AsyncIterableIterator<number> = async function * () { yield* [1, 2]; }; const assignability4: () => AsyncIterableIterator<number> = async function * () { yield* [Promise.resolve(1)]; }; const assignability5: () => AsyncIterableIterator<number> = async function * () { yield* (async function * () { yield 1; })(); }; const assignability6: () => AsyncIterable<number> = async function * () { yield 1; }; const assignability7: () => AsyncIterable<number> = async function * () { yield Promise.resolve(1); }; const assignability8: () => AsyncIterable<number> = async function * () { yield* [1, 2]; }; const assignability9: () => AsyncIterable<number> = async function * () { yield* [Promise.resolve(1)]; }; const assignability10: () => AsyncIterable<number> = async function * () { yield* (async function * () { yield 1; })(); }; const assignability11: () => AsyncIterator<number> = async function * () { yield 1; }; const assignability12: () => AsyncIterator<number> = async function * () { yield Promise.resolve(1); }; const assignability13: () => AsyncIterator<number> = async function * () { yield* [1, 2]; }; const assignability14: () => AsyncIterator<number> = async function * () { yield* [Promise.resolve(1)]; }; const assignability15: () => AsyncIterator<number> = async function * () { yield* (async function * () { yield 1; })(); }; async function * explicitReturnType1(): AsyncIterableIterator<number> { yield 1; } async function * explicitReturnType2(): AsyncIterableIterator<number> { yield Promise.resolve(1); } async function * explicitReturnType3(): AsyncIterableIterator<number> { yield* [1, 2]; } async function * explicitReturnType4(): AsyncIterableIterator<number> { yield* [Promise.resolve(1)]; } async function * explicitReturnType5(): AsyncIterableIterator<number> { yield* (async function * () { yield 1; })(); } async function * explicitReturnType6(): AsyncIterable<number> { yield 1; } async function * explicitReturnType7(): AsyncIterable<number> { yield Promise.resolve(1); } async function * explicitReturnType8(): AsyncIterable<number> { yield* [1, 2]; } async function * explicitReturnType9(): AsyncIterable<number> { yield* [Promise.resolve(1)]; } async function * explicitReturnType10(): AsyncIterable<number> { yield* (async function * () { yield 1; })(); } async function * explicitReturnType11(): AsyncIterator<number> { yield 1; } async function * explicitReturnType12(): AsyncIterator<number> { yield Promise.resolve(1); } async function * explicitReturnType13(): AsyncIterator<number> { yield* [1, 2]; } async function * explicitReturnType14(): AsyncIterator<number> { yield* [Promise.resolve(1)]; } async function * explicitReturnType15(): AsyncIterator<number> { yield* (async function * () { yield 1; })(); } async function * explicitReturnType16(): {} { yield 1; } async function * awaitedType1() { const x = await 1; } async function * awaitedType2() { const x = await Promise.resolve(1); } async function * nextType1(): { next(...args: [] | [number | PromiseLike<number>]): any } { const x = yield; // `number | PromiseLike<number>` (should not await TNext) }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/types.asyncGenerators.es2018.2.ts
TypeScript
// @target: es2018 // @lib: esnext // @noEmit: true async function * inferReturnType1() { yield* {}; } async function * inferReturnType2() { yield* inferReturnType2(); } async function * inferReturnType3() { yield* Promise.resolve([1, 2]); } const assignability1: () => AsyncIterableIterator<number> = async function * () { yield "a"; }; const assignability2: () => AsyncIterableIterator<number> = async function * () { yield* ["a", "b"]; }; const assignability3: () => AsyncIterableIterator<number> = async function * () { yield* (async function * () { yield "a"; })(); }; const assignability4: () => AsyncIterable<number> = async function * () { yield "a"; }; const assignability5: () => AsyncIterable<number> = async function * () { yield* ["a", "b"]; }; const assignability6: () => AsyncIterable<number> = async function * () { yield* (async function * () { yield "a"; })(); }; const assignability7: () => AsyncIterator<number> = async function * () { yield "a"; }; const assignability8: () => AsyncIterator<number> = async function * () { yield* ["a", "b"]; }; const assignability9: () => AsyncIterator<number> = async function * () { yield* (async function * () { yield "a"; })(); }; async function * explicitReturnType1(): AsyncIterableIterator<number> { yield "a"; } async function * explicitReturnType2(): AsyncIterableIterator<number> { yield* ["a", "b"]; } async function * explicitReturnType3(): AsyncIterableIterator<number> { yield* (async function * () { yield "a"; })(); } async function * explicitReturnType4(): AsyncIterable<number> { yield "a"; } async function * explicitReturnType5(): AsyncIterable<number> { yield* ["a", "b"]; } async function * explicitReturnType6(): AsyncIterable<number> { yield* (async function * () { yield "a"; })(); } async function * explicitReturnType7(): AsyncIterator<number> { yield "a"; } async function * explicitReturnType8(): AsyncIterator<number> { yield* ["a", "b"]; } async function * explicitReturnType9(): AsyncIterator<number> { yield* (async function * () { yield "a"; })(); } async function * explicitReturnType10(): IterableIterator<number> { yield 1; } async function * explicitReturnType11(): Iterable<number> { yield 1; } async function * explicitReturnType12(): Iterator<number> { yield 1; } async function * yieldStar() { yield* {}; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/types.forAwait.es2018.1.ts
TypeScript
// @target: es2018 // @lib: esnext // @noEmit: true declare const asyncIterable: AsyncIterable<number>; declare const iterable: Iterable<number>; declare const iterableOfPromise: Iterable<Promise<number>>; async function f1() { let y: number; for await (const x of asyncIterable) { } for await (const x of iterable) { } for await (const x of iterableOfPromise) { } for await (y of asyncIterable) { } for await (y of iterable) { } for await (y of iterableOfPromise) { } } async function * f2() { let y: number; for await (const x of asyncIterable) { } for await (const x of iterable) { } for await (const x of iterableOfPromise) { } for await (y of asyncIterable) { } for await (y of iterable) { } for await (y of iterableOfPromise) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/types.forAwait.es2018.2.ts
TypeScript
// @target: es2018 // @lib: esnext // @noEmit: true declare const asyncIterable: AsyncIterable<number>; declare const iterable: Iterable<number>; async function f() { let y: number; let z: string; for await (const x of {}) { } for await (y of {}) { } for await (z of asyncIterable) { } for await (z of iterable) { } for (const x of asyncIterable) { } for (y of asyncIterable) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/types.forAwait.es2018.3.ts
TypeScript
// @target: es2018 // @lib: es5 // @noEmit: true async function f1() { let y: number; for await (const x of {}) { } for await (y of {}) { } } async function* f2() { let y: number; for await (const x of {}) { } for await (y of {}) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typesOnlyExternalModuleStillHasInstance.ts
TypeScript
// @module: commonjs // @Filename: foo_0.ts export interface Person { name: string; age: number; } export module M2 { export interface I2 { x: Person; } } // @Filename: foo_1.ts import foo0 = require('./foo_0'); // Per 11.2.3, foo_0 should still be "instantiated", albeit with no members var x: typeof foo0 = {}; var y: {M2: Object} = foo0;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typesWithDuplicateTypeParameters.ts
TypeScript
class C<T, T> { } class C2<T, U, T> { } interface I<T, T> { } interface I2<T, U, T> { } function f<T, T>() { } function f2<T, U, T>() { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typesWithOptionalProperty.ts
TypeScript
// basic uses of optional properties without errors interface I { foo: string; bar?: number; baz? (): string; } var a: { foo: string; bar?: number; baz? (): string; }; var b = { foo: '' }; var c = { foo: '', bar: 3 }; var d = { foo: '', bar: 3, baz: () => '' }; var i: I; i = b; i = c; i = d; a = b; a = c; a = d; i = a; a = i;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typesWithPrivateConstructor.ts
TypeScript
// @declaration: true class C { private constructor() { } } var c = new C(); // error C is private var r: () => void = c.constructor; class C2 { private constructor(x: number); private constructor(x: any) { } } var c2 = new C2(); // error C2 is private var r2: (x: number) => void = c2.constructor;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typesWithProtectedConstructor.ts
TypeScript
// @declaration: true class C { protected constructor() { } } var c = new C(); // error C is protected var r: () => void = c.constructor; class C2 { protected constructor(x: number); protected constructor(x: any) { } } var c2 = new C2(); // error C2 is protected var r2: (x: number) => void = c2.constructor;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typesWithPublicConstructor.ts
TypeScript
// public is allowed on a constructor but is not meaningful class C { public constructor() { } } var c = new C(); var r: () => void = c.constructor; class C2 { public constructor(x: number); public constructor(x: any) { } } var c2 = new C2(); var r2: (x: number) => void = c2.constructor;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typesWithSpecializedCallSignatures.ts
TypeScript
// basic uses of specialized signatures without errors class Base { foo: string } class Derived1 extends Base { bar: string } class Derived2 extends Base { baz: string } class C { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; foo(x) { return x; } } var c = new C(); interface I { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; } var i: I; var a: { foo(x: 'hi'): Derived1; foo(x: 'bye'): Derived2; foo(x: string): Base; }; c = i; c = a; i = c; i = a; a = c; a = i; var r1: Derived1 = c.foo('hi'); var r2: Derived2 = c.foo('bye'); var r3: Base = c.foo('hm');
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typesWithSpecializedConstructSignatures.ts
TypeScript
// basic uses of specialized signatures without errors class Base { foo: string } class Derived1 extends Base { bar: string } class Derived2 extends Base { baz: string } class C { constructor(x: 'hi'); constructor(x: 'bye'); constructor(x: string); constructor(x) { return x; } } var c = new C('a'); interface I { new(x: 'hi'): Derived1; new(x: 'bye'): Derived2; new(x: string): Base; } var i: I; var a: { new(x: 'hi'): Derived1; new(x: 'bye'): Derived2; new(x: string): Base; }; c = i; c = a; i = a; a = i; var r1 = new C('hi'); var r2: Derived2 = new i('bye'); var r3: Base = new a('hm');
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/typingsLookupAmd.ts
TypeScript
// @traceResolution: true // @noImplicitReferences: true // @currentDirectory: / // @module: amd // @filename: /node_modules/@types/a/index.d.ts export declare class A {} // @filename: /x/node_modules/@types/b/index.d.ts import {A} from "a"; export declare class B extends A {} // @filename: /x/y/foo.ts import {B} from "b";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unannotatedParametersAreOptional.ts
TypeScript
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: test.js function f(x) {} f(); // Always been ok class C { static m(x) {} p = x => {} m(x) {} } C.m(); // Always been ok new C().m(); // Regression #39261 new C().p(); // Regression #39261 const obj = { m(x) {}, p: x => {} }; obj.m(); // Always been ok obj.p(); // Always been ok
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/undefinedAssignableToEveryType.ts
TypeScript
class C { foo: string; } var ac: C; interface I { foo: string; } var ai: I; enum E { A } var ae: E; var b: number = undefined; var c: string = undefined; var d: boolean = undefined; var e: Date = undefined; var f: any = undefined; var g: void = undefined; var h: Object = undefined; var i: {} = undefined; var j: () => {} = undefined; var k: Function = undefined; var l: (x: number) => string = undefined; ac = undefined; ai = undefined; ae = undefined; var m: number[] = undefined; var n: { foo: string } = undefined; var o: <T>(x: T) => T = undefined; var p: Number = undefined; var q: String = undefined; function foo<T, U, V extends Date>(x: T, y: U, z: V) { x = undefined; y = undefined; z = undefined; } //function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) { // x = undefined; // y = undefined; // z = undefined; //}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/undefinedIsSubtypeOfEverything.ts
TypeScript
// undefined is a subtype of every other types, no errors expected below class Base { foo: typeof undefined; } class D0 extends Base { foo: any; } class DA extends Base { foo: typeof undefined; } class D1 extends Base { foo: string; } class D1A extends Base { foo: String; } class D2 extends Base { foo: number; } class D2A extends Base { foo: Number; } class D3 extends Base { foo: boolean; } class D3A extends Base { foo: Boolean; } class D4 extends Base { foo: RegExp; } class D5 extends Base { foo: Date; } class D6 extends Base { foo: number[]; } class D7 extends Base { foo: { bar: number }; } class D8 extends Base { foo: D7; } interface I1 { bar: string; } class D9 extends Base { foo: I1; } class D10 extends Base { foo: () => number; } enum E { A } class D11 extends Base { foo: E; } function f() { } module f { export var bar = 1; } class D12 extends Base { foo: typeof f; } class c { baz: string } module c { export var bar = 1; } class D13 extends Base { foo: typeof c; } class D14<T> extends Base { foo: T; } class D15<T, U> extends Base { foo: U; } //class D15<T, U extends T> extends Base { // foo: U; //} class D16 extends Base { foo: Object; } class D17 extends Base { foo: {}; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions01_ES5.ts
TypeScript
// @target: es5 var x = /\u{0}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions01_ES6.ts
TypeScript
// @target: es6 var x = /\u{0}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions02_ES5.ts
TypeScript
// @target: es5 var x = /\u{00}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions02_ES6.ts
TypeScript
// @target: es6 var x = /\u{00}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions03_ES5.ts
TypeScript
// @target: es5 var x = /\u{0000}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions03_ES6.ts
TypeScript
// @target: es6 var x = /\u{0000}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions04_ES5.ts
TypeScript
// @target: es5 var x = /\u{00000000}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions04_ES6.ts
TypeScript
// @target: es6 var x = /\u{00000000}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions05_ES5.ts
TypeScript
// @target: es5 var x = /\u{48}\u{65}\u{6c}\u{6c}\u{6f}\u{20}\u{77}\u{6f}\u{72}\u{6c}\u{64}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions05_ES6.ts
TypeScript
// @target: es6 var x = /\u{48}\u{65}\u{6c}\u{6c}\u{6f}\u{20}\u{77}\u{6f}\u{72}\u{6c}\u{64}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions06_ES5.ts
TypeScript
// @target: es5 // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) // 1. Assert: 0 ≤ cp ≤ 0x10FFFF. var x = /\u{10FFFF}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions06_ES6.ts
TypeScript
// @target: es6 // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) // 1. Assert: 0 ≤ cp ≤ 0x10FFFF. var x = /\u{10FFFF}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions07_ES5.ts
TypeScript
// @target: es5 // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) // 1. Assert: 0 ≤ cp ≤ 0x10FFFF. var x = /\u{110000}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions07_ES6.ts
TypeScript
// @target: es6 // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) // 1. Assert: 0 ≤ cp ≤ 0x10FFFF. var x = /\u{110000}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions08_ES5.ts
TypeScript
// @target: es5 // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) // 2. If cp ≤ 65535, return cp. // (FFFF == 65535) var x = /\u{FFFF}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions08_ES6.ts
TypeScript
// @target: es6 // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) // 2. If cp ≤ 65535, return cp. // (FFFF == 65535) var x = /\u{FFFF}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions09_ES5.ts
TypeScript
// @target: es5 // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) // 2. If cp ≤ 65535, return cp. // (10000 == 65536) var x = /\u{10000}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions09_ES6.ts
TypeScript
// @target: es6 // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) // 2. If cp ≤ 65535, return cp. // (10000 == 65536) var x = /\u{10000}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions10_ES5.ts
TypeScript
// @target: es5 // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) // 2. Let cu1 be floor((cp – 65536) / 1024) + 0xD800. // Although we should just get back a single code point value of 0xD800, // this is a useful edge-case test. var x = /\u{D800}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/unicodeExtendedEscapesInRegularExpressions10_ES6.ts
TypeScript
// @target: es6 // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) // 2. Let cu1 be floor((cp – 65536) / 1024) + 0xD800. // Although we should just get back a single code point value of 0xD800, // this is a useful edge-case test. var x = /\u{D800}/g;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University