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/intersectionTypeOverloading.ts
TypeScript
// Check that order is preserved in intersection types for purposes of // overload resolution type F = (s: string) => string; type G = (x: any) => any; var fg: F & G; var gf: G & F; var x = fg("abc"); var x: string; var y = gf("abc"); var y: any;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/intersectionTypeReadonly.ts
TypeScript
interface Base { readonly value: number; } interface Identical { readonly value: number; } interface Mutable { value: number; } interface DifferentType { readonly value: string; } interface DifferentName { readonly other: number; } let base: Base; base.value = 12 // error, lhs can't be a readonly property let identical: Base & Identical; identical.value = 12; // error, lhs can't be a readonly property let mutable: Base & Mutable; mutable.value = 12; let differentType: Base & DifferentType; differentType.value = 12; // error, lhs can't be a readonly property let differentName: Base & DifferentName; differentName.value = 12; // error, property 'value' doesn't exist
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/intersectionWithIndexSignatures.ts
TypeScript
// @strict: true type A = { a: string }; type B = { b: string }; declare let sa1: { x: A & B }; declare let sa2: { x: A } & { x: B }; declare let ta1: { [key: string]: A & B }; declare let ta2: { [key: string]: A } & { [key: string]: B }; ta1 = sa1; ta1 = sa2; ta2 = sa1; ta2 = sa2; declare let sb1: { x: A } & { y: B }; declare let tb1: { [key: string]: A }; tb1 = sb1; // Error // Repro from #32484 type constr<Source, Tgt> = { [K in keyof Source]: string } & Pick<Tgt, Exclude<keyof Tgt, keyof Source>>; type s = constr<{}, { [key: string]: { a: string } }>; declare const q: s; q["asd"].a.substr(1); q["asd"].b; // Error const d: { [key: string]: {a: string, b: string} } = q; // Error // Repro from #32484 declare let ss: { a: string } & { b: number }; declare let tt: { [key: string]: string }; tt = ss; // Error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/intersectionWithUnionConstraint.ts
TypeScript
// @strict: true function f1<T extends string | number, U extends string | number>(x: T & U) { // Combined constraint of 'T & U' is 'string | number' let y: string | number = x; } function f2<T extends string | number | undefined, U extends string | null | undefined>(x: T & U) { let y1: string | number = x; // Error let y2: string | null = x; // Error let y3: string | undefined = x; let y4: number | null = x; // Error let y5: number | undefined = x; // Error let y6: null | undefined = x; // Error } type T1 = (string | number | undefined) & (string | null | undefined); // string | undefined function f3<T extends string | number | undefined>(x: T & (number | object | undefined)) { const y: number | undefined = x; } function f4<T extends string | number>(x: T & (number | object)) { const y: number = x; } function f5<T, U extends keyof T>(x: keyof T & U) { let y: keyof any = x; } // Repro from #23648 type Example<T, U> = { [K in keyof T]: K extends keyof U ? UnexpectedError<K> : NoErrorHere<K> } type UnexpectedError<T extends PropertyKey> = T type NoErrorHere<T extends PropertyKey> = T // Repro from #30331 type a<T> = T extends Array<infer U> ? U : never; type b<T> = { [K in a<T> & keyof T ]: 42 };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/intersectionsAndEmptyObjects.ts
TypeScript
// @target: es2015 // @module: commonjs // @esModuleInterop: true // @filename: intersectionsAndEmptyObjects.ts // Empty object type literals are removed from intersections types // that contain other object types type A = { a: number }; type B = { b: string }; type C = {}; let x01: A & B; let x02: A & C; let x03: B & C; let x04: A & B & C; let x05: string & C; let x06: C & string; let x07: C; let x08: C & {}; let x09: {} & A & {} & B & {} & C & {}; interface D {} interface E {} let x10: A & D; let x11: C & D; let x12: A & B & C & D; let x13: D & E; let x14: A & B & C & D & E; // Repro from #20225 type Dictionary = { [name: string]: string }; const intersectDictionaries = <F1 extends Dictionary, F2 extends Dictionary>( d1: F1, d2: F2, ): F1 & F2 => Object.assign({}, d1, d2); const testDictionary = <T extends Dictionary>(_value: T) => { }; const d1 = {}; testDictionary(d1); const d2 = intersectDictionaries(d1, d1); testDictionary(d2); const d3 = { s: '', }; testDictionary(d3); const d4 = intersectDictionaries(d1, d3); testDictionary(d4); const d5 = intersectDictionaries(d3, d1); testDictionary(d5); const d6 = intersectDictionaries(d3, d3); testDictionary(d6); // Repro from #27044 type choices<IChoiceList extends { [key: string]: boolean; }> = IChoiceList & { shoes:boolean; food:boolean; }; type IMyChoiceList = { car: true }; type IUnknownChoiceList = {}; var defaultChoices: choices<{}>; var defaultChoicesAndEmpty: choices<{} & {}>; var myChoices: choices<IMyChoiceList>; var myChoicesAndEmpty: choices<IMyChoiceList & {}>; var unknownChoices: choices<IUnknownChoiceList>; var unknownChoicesAndEmpty: choices<IUnknownChoiceList & {}>; // Repro from #38672 type Foo1 = { x: string } & { [x: number]: Foo1 }; type Foo2 = { x: string } & { [K in number]: Foo2 }; // Repro from #40239 declare function mock<M>(_: Promise<M>): {} & M; mock(import('./ex')) // @filename: ex.d.ts export {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/intlDateTimeFormatRangeES2021.ts
TypeScript
// @lib: es2021 new Intl.DateTimeFormat().formatRange(new Date(0), new Date()); const [ part ] = new Intl.DateTimeFormat().formatRangeToParts(1000, 1000000000);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2020.ts
TypeScript
// @target: es2020 // @strict: true // New/updated resolved options in ES2020 const { notation, style, signDisplay } = new Intl.NumberFormat('en-NZ').resolvedOptions(); // Empty options new Intl.NumberFormat('en-NZ', {}); // Override numbering system new Intl.NumberFormat('en-NZ', { numberingSystem: 'arab' }); // Currency const { currency, currencySign } = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).resolvedOptions(); // Units const { unit, unitDisplay } = new Intl.NumberFormat('en-NZ', { style: 'unit', unit: 'kilogram', unitDisplay: 'narrow' }).resolvedOptions(); // Compact const { compactDisplay } = new Intl.NumberFormat('en-NZ', { notation: 'compact', compactDisplay: 'long' }).resolvedOptions(); // Sign display new Intl.NumberFormat('en-NZ', { signDisplay: 'always' }); // New additions to NumberFormatPartTypes const types: Intl.NumberFormatPartTypes[] = [ 'compact', 'unit', 'unknown' ];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2023.ts
TypeScript
// @target: es2022 // @lib: es2022,es2023.intl // @strict: true // New / updated resolved options in ES2023, including type change for useGrouping const { roundingPriority, roundingMode, roundingIncrement, trailingZeroDisplay, useGrouping } = new Intl.NumberFormat('en-GB').resolvedOptions(); // Empty options new Intl.NumberFormat('en-GB', {}); // Rounding new Intl.NumberFormat('en-GB', { roundingPriority: 'lessPrecision', roundingIncrement: 100, roundingMode: 'trunc' }); // Changes to signDisplay const { signDisplay } = new Intl.NumberFormat('en-GB', { signDisplay: 'negative' }).resolvedOptions(); // Changes to useGrouping new Intl.NumberFormat('en-GB', { useGrouping: true }); new Intl.NumberFormat('en-GB', { useGrouping: 'true' }); new Intl.NumberFormat('en-GB', { useGrouping: 'always' }); // formatRange new Intl.NumberFormat('en-GB').formatRange(10, 100); new Intl.NumberFormat('en-GB').formatRange(10n, 1000n); new Intl.NumberFormat('en-GB').formatRangeToParts(10, 1000)[0]; new Intl.NumberFormat('en-GB').formatRangeToParts(10n, 1000n)[0]; // Arbitrary-precision string arguments new Intl.NumberFormat('en-GB').format('-12.3E-4'); new Intl.NumberFormat('en-GB').formatRange('123.4', '567.8'); new Intl.NumberFormat('en-GB').formatRangeToParts('123E-4', '567E8'); new Intl.NumberFormat('en-GB').format('Infinity'); new Intl.NumberFormat('en-GB').format('-Infinity'); new Intl.NumberFormat('en-GB').format('+Infinity');
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/intlNumberFormatES5UseGrouping.ts
TypeScript
// @target: es5 // @strict: true new Intl.NumberFormat('en-GB', { useGrouping: true }); new Intl.NumberFormat('en-GB', { useGrouping: 'true' }); // expect error new Intl.NumberFormat('en-GB', { useGrouping: 'always' }); // expect error const { useGrouping } = new Intl.NumberFormat('en-GB').resolvedOptions();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/intraExpressionInferences.ts
TypeScript
// @strict: true // @declaration: true // Repros from #47599 declare function callIt<T>(obj: { produce: (n: number) => T, consume: (x: T) => void }): void; callIt({ produce: () => 0, consume: n => n.toFixed() }); callIt({ produce: _a => 0, consume: n => n.toFixed(), }); callIt({ produce() { return 0; }, consume: n => n.toFixed() }); declare function callItT<T>(obj: [(n: number) => T, (x: T) => void]): void; callItT([() => 0, n => n.toFixed()]); callItT([_a => 0, n => n.toFixed()]); // Repro from #25092 interface MyInterface<T> { retrieveGeneric: (parameter: string) => T, operateWithGeneric: (generic: T) => string } const inferTypeFn = <T>(generic: MyInterface<T>) => generic; const myGeneric = inferTypeFn({ retrieveGeneric: parameter => 5, operateWithGeneric: generic => generic.toFixed() }); // Repro #38623 function make<M>(o: { mutations: M, action: (m: M) => void }) { } make({ mutations: { foo() { } }, action: (a) => { a.foo() } }); // Repro from #38845 declare function foo<A>(options: { a: A, b: (a: A) => void }): void; foo({ a: () => { return 42 }, b(a) {}, }); foo({ a: function () { return 42 }, b(a) {}, }); foo({ a() { return 42 }, b(a) {}, }); // Repro from #38872 type Chain<R1, R2> = { a(): R1, b(a: R1): R2; c(b: R2): void; }; function test<R1, R2>(foo: Chain<R1, R2>) {} test({ a: () => 0, b: (a) => 'a', c: (b) => { const x: string = b; } }); test({ a: () => 0, b: (a) => a, c: (b) => { const x: number = b; } }); // Repro from #41712 class Wrapper<T = any> { public value?: T; } type WrappedMap = Record<string, Wrapper>; type Unwrap<D extends WrappedMap> = { [K in keyof D]: D[K] extends Wrapper<infer T> ? T : never; }; type MappingComponent<I extends WrappedMap, O extends WrappedMap> = { setup(): { inputs: I; outputs: O }; map?: (inputs: Unwrap<I>) => Unwrap<O>; }; declare function createMappingComponent<I extends WrappedMap, O extends WrappedMap>(def: MappingComponent<I, O>): void; createMappingComponent({ setup() { return { inputs: { num: new Wrapper<number>(), str: new Wrapper<string>() }, outputs: { bool: new Wrapper<boolean>(), str: new Wrapper<string>() } }; }, map(inputs) { return { bool: inputs.nonexistent, str: inputs.num, // Causes error } } }); // Repro from #48279 function simplified<T>(props: { generator: () => T, receiver: (t: T) => any }) {} function whatIWant<T>(props: { generator: (bob: any) => T, receiver: (t: T) => any }) {} function nonObject<T>(generator: (bob: any) => T, receiver: (t: T) => any) {} simplified({ generator: () => 123, receiver: (t) => console.log(t + 2) }) whatIWant({ generator: (bob) => bob ? 1 : 2, receiver: (t) => console.log(t + 2) }) nonObject((bob) => bob ? 1 : 2, (t) => console.log(t + 2)) // Repro from #48466 interface Opts<TParams, TDone, TMapped> { fetch: (params: TParams, foo: number) => TDone, map: (data: TDone) => TMapped } function example<TParams, TDone, TMapped>(options: Opts<TParams, TDone, TMapped>) { return (params: TParams) => { const data = options.fetch(params, 123) return options.map(data) } } interface Params { one: number two: string } example({ fetch: (params: Params) => 123, map: (number) => String(number) }); example({ fetch: (params: Params, foo: number) => 123, map: (number) => String(number) }); example({ fetch: (params: Params, foo) => 123, map: (number) => String(number) }); // Repro from #45255 declare const branch: <T, U extends T>(_: { test: T, if: (t: T) => t is U, then: (u: U) => void }) => void declare const x: "a" | "b" branch({ test: x, if: (t): t is "a" => t === "a", then: u => { let test1: "a" = u } }) interface Props<T> { a: (x: string) => T; b: (arg: T) => void; } declare function Foo<T>(props: Props<T>): null; Foo({ ...{ a: (x) => 10, b: (arg) => { arg.toString(); }, }, }); declare function nested<T>(arg: { prop: { produce: (arg1: number) => T; consume: (arg2: T) => void; }; }): T; const resNested = nested({ prop: { produce: (a) => [a], consume: (arg) => arg.join(","), }, }); declare function twoConsumers<T>(arg: { a: (arg: string) => T; consume1: (arg1: T) => void; consume2: (arg2: T) => void; }): T; const resTwoConsumers = twoConsumers({ a: (arg) => [arg], consume1: (arg1) => {}, consume2: (arg2) => {}, }); declare function multipleProducersBeforeConsumers<T, T2>(arg: { a: (arg: string) => T; b: (arg: string) => T2; consume1: (arg1: T) => void; consume2: (arg2: T2) => void; }): [T, T2]; const resMultipleProducersBeforeConsumers = multipleProducersBeforeConsumers({ a: (arg) => [arg], b: (arg) => Number(arg), consume1: (arg1) => {}, consume2: (arg2) => {}, }); declare function withConditionalExpression<T, T2, T3>(arg: { a: (arg1: string) => T; b: (arg2: T) => T2; c: (arg2: T2) => T3; }): [T, T2, T3]; const resWithConditionalExpression = withConditionalExpression({ a: (arg) => [arg], b: Math.random() ? (arg) => "first" as const : (arg) => "two" as const, c: (arg) => Boolean(arg), }); declare function onion<T, T2, T3>(arg: { a: (arg1: string) => T; nested: { b: (arg2: T) => T2; nested2: { c: (arg2: T2) => T3; }; }; }): [T, T2, T3]; const resOnion = onion({ a: (arg) => [arg], nested: { b: (arg) => arg.join(","), nested2: { c: (arg) => Boolean(arg), }, }, }); declare function onion2<T, T2, T3, T4>(arg: { a: (arg1: string) => T; nested: { b: (arg2: T) => T2; c: (arg3: T) => T3; nested2: { d: (arg4: T3) => T4; }; }; }): [T, T2, T3, T4]; const resOnion2 = onion2({ a: (arg) => [arg], nested: { b: (arg) => arg.join(","), c: (arg) => Number(arg), nested2: { d: (arg) => Boolean(arg), }, }, }); declare function distant<T>(args: { foo: { bar: { baz: { producer: (arg: string) => T; }; }; }; consumer: (val: T) => unknown; }): T; const distantRes = distant({ foo: { bar: { baz: { producer: (arg) => 1, }, }, }, consumer: (val) => {}, });
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/intraExpressionInferencesJsx.tsx
TypeScript (TSX)
// @strict: true // @jsx: react-jsx // @noEmit: true /// <reference path="/.lib/react16.d.ts" /> // repro from #52798 type A = { a: boolean; }; type B = { b: string; }; type C = { c: number; }; type Animations = { [key: string]: { value: number } & ( | ({ kind: "a"; func?(): Partial<A> } & A) | ({ kind: "b"; func?(): Partial<B> } & B) | ({ kind: "c"; func?(): Partial<C> } & C) ); }; type StyleParam<T extends Animations> = Record<keyof T, string>; type AnimatedViewProps<T extends Animations> = { style: (animationsValues: StyleParam<T>) => string; animations: T; }; const Component = <T extends Animations>({ animations, style, }: AnimatedViewProps<T>) => <></>; <Component animations={{ test: { kind: "a", value: 1, a: true, }, }} style={(anim) => { return ""; }} />; <Component animations={{ test: { kind: "a", value: 1, a: true, func() { return { a: true, }; }, }, }} style={(anim) => { return ""; }} />; <Component animations={{ test: { kind: "a", value: 1, a: true, func: () => { return { a: true, }; }, }, }} style={(anim) => { return ""; }} />; // repro from #52786 interface Props<T> { a: (x: string) => T; b: (arg: T) => void; } function Foo<T>(props: Props<T>) { return <div />; } <Foo a={() => 10} b={(arg) => { arg.toString(); }} />; <Foo a={(x) => 10} b={(arg) => { arg.toString(); }} />; <Foo {...{ a: (x) => 10, b: (arg) => { arg.toString(); }, }} />;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/intrinsicKeyword.ts
TypeScript
// @strict: true let e1: intrinsic; let e2: { intrinsic: intrinsic }; type TE1 = (intrinsic); type TE2<intrinsic> = intrinsic; type TE3<T extends intrinsic> = T; type TE4<intrinsic extends intrinsic> = intrinsic; type TE5<intrinsic extends intrinsic> = (intrinsic); function f1() { let intrinsic: intrinsic.intrinsic; } function f2(intrinsic: string) { return intrinsic; } function f3() { type intrinsic = string; let s1: intrinsic = 'ok'; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/intrinsicTypes.ts
TypeScript
// @strict: true // @declaration: true type TU1 = Uppercase<'hello'>; // "HELLO" type TU2 = Uppercase<'foo' | 'bar'>; // "FOO" | "BAR" type TU3 = Uppercase<string>; // Uppercase<string> type TU4 = Uppercase<any>; // Uppercase<`${any}`> type TU5 = Uppercase<never>; // never type TU6 = Uppercase<42>; // Error type TL1 = Lowercase<'HELLO'>; // "hello" type TL2 = Lowercase<'FOO' | 'BAR'>; // "foo" | "bar" type TL3 = Lowercase<string>; // Lowercase<string> type TL4 = Lowercase<any>; // Lowercase<`${any}`> type TL5 = Lowercase<never>; // never type TL6 = Lowercase<42>; // Error type TC1 = Capitalize<'hello'>; // "Hello" type TC2 = Capitalize<'foo' | 'bar'>; // "Foo" | "Bar" type TC3 = Capitalize<string>; // Capitalize<string> type TC4 = Capitalize<any>; // Capitalize<`${any}`> type TC5 = Capitalize<never>; // never type TC6 = Capitalize<42>; // Error type TN1 = Uncapitalize<'Hello'>; // "hello" type TN2 = Uncapitalize<'Foo' | 'Bar'>; // "foo" | "bar" type TN3 = Uncapitalize<string>; // Uncapitalize<string> type TN4 = Uncapitalize<any>; // Uncapitalize<`${any}`> type TN5 = Uncapitalize<never>; // never type TN6 = Uncapitalize<42>; // Error type TX1<S extends string> = Uppercase<`aB${S}`>; type TX2 = TX1<'xYz'>; // "ABXYZ" type TX3<S extends string> = Lowercase<`aB${S}`>; type TX4 = TX3<'xYz'>; // "abxyz" type TX5 = `${Uppercase<'abc'>}${Lowercase<'XYZ'>}`; // "ABCxyz" type MyUppercase<S extends string> = intrinsic; // Error function foo1<T extends string, U extends T>(s: string, x: Uppercase<T>, y: Uppercase<U>) { s = x; s = y; x = s; // Error x = y; y = s; // Error y = x; // Error } function foo2<T extends 'foo' | 'bar'>(x: Uppercase<T>) { let s: 'FOO' | 'BAR' = x; } declare function foo3<T extends string>(x: Uppercase<T>): T; function foo4<U extends string>(x: Uppercase<U>) { return foo3(x); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidAssignmentsToVoid.ts
TypeScript
var x: void; x = 1; x = true; x = ''; x = {} class C { foo: string; } var c: C; x = C; x = c; interface I { foo: string; } var i: I; x = i; module M { export var x = 1; } x = M; function f<T>(a: T) { x = a; } x = f;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidBooleanAssignments.ts
TypeScript
var x = true; var a: number = x; var b: string = x; var c: void = x; var d: typeof undefined = x; enum E { A } var e: E = x; class C { foo: string } var f: C = x; interface I { bar: string } var g: I = x; var h: { (): string } = x; var h2: { toString(): string } = x; // no error module M { export var a = 1; } M = x; function i<T>(a: T) { a = x; } i = x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidEnumAssignments.ts
TypeScript
enum E { A, B } enum E2 { A, B } var e: E; var e2: E2; e = E2.A; e2 = E.A; e = <void>null; e = {}; e = ''; function f<T>(a: T) { e = a; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidImportAliasIdentifiers.ts
TypeScript
// none of these should work, since non are actually modules var V = 12; import v = V; class C { name: string; } import c = C; enum E { Red, Blue } import e = E; interface I { id: number; } import i = I;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidInstantiatedModule.ts
TypeScript
module M { export class Point { x: number; y: number } export var Point = 1; // Error } module M2 { export interface Point { x: number; y: number } export var Point = 1; } var m = M2; var p: m.Point; // Error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidMultipleVariableDeclarations.ts
TypeScript
interface I { id: number; } class C implements I { id: number; valid: boolean; } class C2 extends C { name: string; } class D<T>{ source: T; recurse: D<T>; wrapped: D<D<T>> } function F(x: string): number { return 42; } module M { export class A { name: string; } export function F2(x: number): string { return x.toString(); } } // all of these are errors var a: any; var a = 1; var a = 'a string'; var a = new C(); var a = new D<string>(); var a = M; var b: I; var b = new C(); var b = new C2(); var f = F; var f = (x: number) => ''; var arr: string[]; var arr = [1, 2, 3, 4]; var arr = [new C(), new C2(), new D<string>()]; var arr2 = [new D<string>()]; var arr2 = new Array<D<number>>(); var m: typeof M; var m = M.A;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidNestedModules.ts
TypeScript
module A.B.C { export class Point { x: number; y: number; } } module A { export module B { export class C { // Error name: string; } } } module M2.X { export class Point { x: number; y: number; } } module M2 { export module X { export var Point: number; // Error } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidNumberAssignments.ts
TypeScript
var x = 1; var a: boolean = x; var b: string = x; var c: void = x; var d: typeof undefined = x; class C { foo: string; } var e: C = x; interface I { bar: string; } var f: I = x; var g: { baz: string } = 1; var g2: { 0: number } = 1; module M { export var x = 1; } M = x; function i<T>(a: T) { a = x; } i = x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidReturnStatements.ts
TypeScript
// all the following should be error function fn1(): number { } function fn2(): string { } function fn3(): boolean { } function fn4(): Date { } function fn7(): any { } // should be valid: any includes void interface I { id: number } class C implements I { id: number; dispose() {} } class D extends C { name: string; } function fn10(): D { return { id: 12 }; } function fn11(): D { return new C(); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidStringAssignments.ts
TypeScript
var x = ''; var a: boolean = x; var b: number = x; var c: void = x; var d: typeof undefined = x; class C { foo: string; } var e: C = x; interface I { bar: string; } var f: I = x; var g: { baz: string } = 1; var g2: { 0: number } = 1; module M { export var x = 1; } M = x; function i<T>(a: T) { a = x; } i = x; enum E { A } var j: E = x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidSwitchBreakStatement.ts
TypeScript
// break is not allowed in a switch statement switch (12) { case 5: break; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidUndefinedAssignments.ts
TypeScript
var x: typeof undefined; enum E { A } E = x; E.A = x; class C { foo: string } var f: C; C = x; interface I { foo: string } var g: I; g = x; I = x; module M { export var x = 1; } M = x; function i<T>(a: T) { } // BUG 767030 i = x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidUndefinedValues.ts
TypeScript
var x: typeof undefined; x = 1; x = ''; x = true; var a: void; x = a; x = null; class C { foo: string } var b: C; x = C; x = b; interface I { foo: string } var c: I; x = c; module M { export var x = 1; } x = M; x = { f() { } } function f<T>(a: T) { x = a; } x = f; enum E { A } x = E; x = E.A;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidVoidAssignments.ts
TypeScript
var x: void; var a: boolean = x; var b: string = x; var c: number = x; var d: typeof undefined = x; class C { foo: string; } var e: C = x; interface I { bar: string; } var f: I = x; var g: { baz: string } = 1; var g2: { 0: number } = 1; module M { export var x = 1; } M = x; function i<T>(a: T) { a = x; } i = x; enum E { A } x = E; x = E.A; x = { f() { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/invalidVoidValues.ts
TypeScript
var x: void; x = 1; x = ''; x = true; enum E { A } x = E; x = E.A; class C { foo: string } var a: C; x = a; interface I { foo: string } var b: I; x = b; x = { f() {} } module M { export var x = 1; } x = M; function f<T>(a: T) { x = a; } x = f;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/isomorphicMappedTypeInference.ts
TypeScript
// @strictNullChecks: true // @noimplicitany: true // @declaration: true type Box<T> = { value: T; } type Boxified<T> = { [P in keyof T]: Box<T[P]>; } function box<T>(x: T): Box<T> { return { value: x }; } function unbox<T>(x: Box<T>): T { return x.value; } function boxify<T>(obj: T): Boxified<T> { let result = {} as Boxified<T>; for (let k in obj) { result[k] = box(obj[k]); } return result; } function unboxify<T extends object>(obj: Boxified<T>): T { let result = {} as T; for (let k in obj) { result[k] = unbox(obj[k]); } return result; } function assignBoxified<T>(obj: Boxified<T>, values: T) { for (let k in values) { obj[k].value = values[k]; } } function f1() { let v = { a: 42, b: "hello", c: true }; let b = boxify(v); let x: number = b.a.value; } function f2() { let b = { a: box(42), b: box("hello"), c: box(true) }; let v = unboxify(b); let x: number = v.a; } function f3() { let b = { a: box(42), b: box("hello"), c: box(true) }; assignBoxified(b, { c: false }); } function f4() { let b = { a: box(42), b: box("hello"), c: box(true) }; b = boxify(unboxify(b)); b = unboxify(boxify(b)); } function makeRecord<T, K extends string>(obj: { [P in K]: T }) { return obj; } function f5(s: string) { let b = makeRecord({ a: box(42), b: box("hello"), c: box(true) }); let v = unboxify(b); let x: string | number | boolean = v.a; } function makeDictionary<T>(obj: { [x: string]: T }) { return obj; } function f6(s: string) { let b = makeDictionary({ a: box(42), b: box("hello"), c: box(true) }); let v = unboxify(b); let x: string | number | boolean = v[s]; } declare function validate<T>(obj: { [P in keyof T]?: T[P] }): T; declare function clone<T>(obj: { readonly [P in keyof T]: T[P] }): T; declare function validateAndClone<T>(obj: { readonly [P in keyof T]?: T[P] }): T; type Foo = { a?: number; readonly b: string; } function f10(foo: Foo) { let x = validate(foo); // { a: number, readonly b: string } let y = clone(foo); // { a?: number, b: string } let z = validateAndClone(foo); // { a: number, b: string } } // Repro from #12606 type Func<T> = (...args: any[]) => T; type Spec<T> = { [P in keyof T]: Func<T[P]> | Spec<T[P]> ; }; /** * Given a spec object recursively mapping properties to functions, creates a function * producing an object of the same structure, by mapping each property to the result * of calling its associated function with the supplied arguments. */ declare function applySpec<T>(obj: Spec<T>): (...args: any[]) => T; // Infers g1: (...args: any[]) => { sum: number, nested: { mul: string } } var g1 = applySpec({ sum: (a: any) => 3, nested: { mul: (b: any) => "n" } }); // Infers g2: (...args: any[]) => { foo: { bar: { baz: boolean } } } var g2 = applySpec({ foo: { bar: { baz: (x: any) => true } } }); // Repro from #12633 const foo = <T>(object: T, partial: Partial<T>) => object; let o = {a: 5, b: 7}; foo(o, {b: 9}); o = foo(o, {b: 9}); // Inferring to { [P in K]: X }, where K extends keyof T, produces same inferences as // inferring to { [P in keyof T]: X }. declare function f20<T, K extends keyof T>(obj: Pick<T, K>): T; declare function f21<T, K extends keyof T>(obj: Pick<T, K>): K; declare function f22<T, K extends keyof T>(obj: Boxified<Pick<T, K>>): T; declare function f23<T, U extends keyof T, K extends U>(obj: Pick<T, K>): T; declare function f24<T, U, K extends keyof T | keyof U>(obj: Pick<T & U, K>): T & U; let x0 = f20({ foo: 42, bar: "hello" }); let x1 = f21({ foo: 42, bar: "hello" }); let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); let x3 = f23({ foo: 42, bar: "hello" }); let x4 = f24({ foo: 42, bar: "hello" }); // Repro from #29765 function getProps<T, K extends keyof T>(obj: T, list: K[]): Pick<T, K> { return {} as any; } const myAny: any = {}; const o1 = getProps(myAny, ['foo', 'bar']); const o2: { foo: any; bar: any } = getProps(myAny, ['foo', 'bar']);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern1.ts
TypeScript
//@target: ES6 class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } var [a, b] = new SymbolIterator;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern10.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } function fun([a, b]) { } fun(new FooIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern11.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } function fun([a, b] = new FooIterator) { } fun(new FooIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern12.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } function fun([a, ...b] = new FooIterator) { } fun(new FooIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern13.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } function fun([a, ...b]) { } fun(new FooIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern14.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } function fun(...[a, ...b]) { } fun(new FooIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern15.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } function fun(...[a, b]: Bar[]) { } fun(...new FooIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern16.ts
TypeScript
//@target: ES6 function fun(...[a, b]: [Bar, Bar][]) { } fun(...new FooIteratorIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } class FooIteratorIterator { next() { return { value: new FooIterator, done: false }; } [Symbol.iterator]() { return this; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern17.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } function fun(...[a, b]: Bar[]) { } fun(new FooIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern18.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } function fun([a, b]: Bar[]) { } fun(new FooIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern19.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooArrayIterator { next() { return { value: [new Foo], done: false }; } [Symbol.iterator]() { return this; } } function fun([[a], b]: Bar[][]) { } fun(new FooArrayIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern2.ts
TypeScript
//@target: ES6 class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } var [a, ...b] = new SymbolIterator;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern20.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooArrayIterator { next() { return { value: [new Foo], done: false }; } [Symbol.iterator]() { return this; } } function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } fun(...new FooArrayIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern21.ts
TypeScript
//@target: ES6 var [a, b] = { 0: "", 1: true };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern22.ts
TypeScript
//@target: ES6 var [...a] = { 0: "", 1: true };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern23.ts
TypeScript
//@target: ES6 var a: string, b: boolean; [a, b] = { 0: "", 1: true };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern24.ts
TypeScript
//@target: ES6 var a: string, b: boolean[]; [a, ...b] = { 0: "", 1: true };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern25.ts
TypeScript
//@target: ES6 function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) { } takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern26.ts
TypeScript
//@target: ES6 function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { } takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern27.ts
TypeScript
//@target: ES6 function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { } takeFirstTwoEntries(...new Map([["", 0], ["hello", 1]]));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern28.ts
TypeScript
// @lib: es2015 // @target: ES6 function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { } takeFirstTwoEntries(...new Map([["", 0], ["hello", true]]));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern29.ts
TypeScript
//@target: ES6 function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { } takeFirstTwoEntries(...new Map([["", true], ["hello", true]]));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern3.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } var a: Bar, b: Bar; [a, b] = new FooIterator;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern30.ts
TypeScript
//@target: ES6 const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]])
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern4.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } var a: Bar, b: Bar[]; [a, ...b] = new FooIterator
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern5.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } var a: Bar, b: string; [a, b] = new FooIterator;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern6.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } var a: Bar, b: string[]; [a, ...b] = new FooIterator;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern7.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } var a: Bar, b: string[]; [a, b] = new FooIterator;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern8.ts
TypeScript
//@target: ES6 class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } } var a: Bar, b: string; [a, ...b] = new FooIterator;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableArrayPattern9.ts
TypeScript
//@target: ES6 function fun([a, b] = new FooIterator) { } class Bar { x } class Foo extends Bar { y } class FooIterator { next() { return { value: new Foo, done: false }; } [Symbol.iterator]() { return this; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iterableContextualTyping1.ts
TypeScript
//@target: ES6 var iter: Iterable<(x: string) => number> = [s => s.length];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInArray.ts
TypeScript
//@target: ES6 class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } var array = [...new SymbolIterator];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInArray10.ts
TypeScript
//@target: ES6 class SymbolIterator { [Symbol.iterator]() { return this; } } var array = [...new SymbolIterator];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInArray11.ts
TypeScript
//@target: ES6 var iter: Iterable<number>; var array = [...iter];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInArray2.ts
TypeScript
//@target: ES6 class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } class NumberIterator { next() { return { value: 0, done: false }; } [Symbol.iterator]() { return this; } } var array = [...new NumberIterator, ...new SymbolIterator];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInArray3.ts
TypeScript
//@target: ES6 class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } var array = [...[0, 1], ...new SymbolIterator];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInArray4.ts
TypeScript
//@target: ES6 class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } var array = [0, 1, ...new SymbolIterator];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInArray5.ts
TypeScript
//@target: ES6 class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } var array: number[] = [0, 1, ...new SymbolIterator];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInArray6.ts
TypeScript
//@target: ES6 class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } var array: number[] = [0, 1]; array.concat([...new SymbolIterator]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInArray7.ts
TypeScript
//@target: ES6 class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } var array: symbol[]; array.concat([...new SymbolIterator]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInArray8.ts
TypeScript
//@target: ES6 class SymbolIterator { next() { return { value: Symbol(), done: false }; } } var array = [...new SymbolIterator];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInArray9.ts
TypeScript
//@target: ES6 class SymbolIterator { next() { return { value: Symbol() }; } [Symbol.iterator]() { return this; } } var array = [...new SymbolIterator];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInCall.ts
TypeScript
//@target: ES6 function foo(s: symbol) { } class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } foo(...new SymbolIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInCall10.ts
TypeScript
//@target: ES6 function foo<T>(s: T[]) { return s[0] } class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } foo(...new SymbolIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInCall11.ts
TypeScript
//@target: ES6 function foo<T>(...s: T[]) { return s[0] } class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } foo(...new SymbolIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInCall12.ts
TypeScript
//@target: ES6 class Foo<T> { constructor(...s: T[]) { } } class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } class _StringIterator { next() { return { value: "", done: false }; } [Symbol.iterator]() { return this; } } new Foo(...[...new SymbolIterator, ...[...new _StringIterator]]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInCall2.ts
TypeScript
//@target: ES6 function foo(s: symbol[]) { } class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } foo(...new SymbolIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInCall3.ts
TypeScript
//@target: ES6 function foo(...s: symbol[]) { } class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } foo(...new SymbolIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInCall4.ts
TypeScript
//@target: ES6 function foo(s1: symbol, ...s: symbol[]) { } class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } foo(...new SymbolIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInCall5.ts
TypeScript
//@target: ES6 function foo(...s: (symbol | string)[]) { } class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } class _StringIterator { next() { return { value: "", done: false }; } [Symbol.iterator]() { return this; } } foo(...new SymbolIterator, ...new _StringIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInCall6.ts
TypeScript
//@target: ES6 function foo(...s: (symbol | number)[]) { } class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } class _StringIterator { next() { return { value: "", done: false }; } [Symbol.iterator]() { return this; } } foo(...new SymbolIterator, ...new _StringIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInCall7.ts
TypeScript
//@target: ES6 function foo<T>(...s: T[]) { return s[0]; } class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } class _StringIterator { next() { return { value: "", done: false }; } [Symbol.iterator]() { return this; } } foo(...new SymbolIterator, ...new _StringIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInCall8.ts
TypeScript
//@target: ES6 class Foo<T> { constructor(...s: T[]) { } } class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } class _StringIterator { next() { return { value: "", done: false }; } [Symbol.iterator]() { return this; } } new Foo(...new SymbolIterator, ...new _StringIterator);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/iteratorSpreadInCall9.ts
TypeScript
//@target: ES6 class Foo<T> { constructor(...s: T[]) { } } class SymbolIterator { next() { return { value: Symbol(), done: false }; } [Symbol.iterator]() { return this; } } class _StringIterator { next() { return { value: "", done: false }; } [Symbol.iterator]() { return this; } } new Foo(...new SymbolIterator, ...[...new _StringIterator]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsContainerMergeJsContainer.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // #24131 // @Filename: a.js const a = {}; a.d = function() {}; // @Filename: b.js a.d.prototype = {};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsContainerMergeTsDeclaration.ts
TypeScript
// @allowJs: true // @checkJs: true // @noEmit: true // @Filename: a.js var /*1*/x = function foo() { } x.a = function bar() { } // @Filename: b.ts var x = function () { return 1; }();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsContainerMergeTsDeclaration2.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: a.d.ts declare namespace C { function bar(): void } // @Filename: b.js C.prototype = {}; C.bar = 2;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsContainerMergeTsDeclaration3.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: a.d.ts declare class A {} // @Filename: b.js const A = { }; A.d = { };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassAccessor.ts
TypeScript
// @allowJs: true // @checkJs: true // @target: es2019 // @outDir: ./out // @declaration: true // @filename: supplement.d.ts export { }; declare module "./argument.js" { interface Argument { idlType: any; default: null; } } // @filename: base.js export class Base { constructor() { } toJSON() { const json = { type: undefined, name: undefined, inheritance: undefined }; return json; } } // @filename: argument.js import { Base } from "./base.js"; export class Argument extends Base { /** * @param {*} tokeniser */ static parse(tokeniser) { return; } get type() { return "argument"; } /** * @param {*} defs */ *validate(defs) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassExtendsVisibility.ts
TypeScript
// @allowJs: true // @checkJs: true // @target: es5 // @outDir: ./out // @declaration: true // @filename: bar.js class Bar {} module.exports = Bar; // @filename: cls.js const Bar = require("./bar"); const Strings = { a: "A", b: "B" }; class Foo extends Bar {} module.exports = Foo; module.exports.Strings = Strings;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassImplementsGenericsSerialization.ts
TypeScript
// @allowJs: true // @checkJs: true // @target: es5 // @outDir: ./out // @declaration: true // @filename: interface.ts export interface Encoder<T> { encode(value: T): Uint8Array } // @filename: lib.js /** * @template T * @implements {IEncoder<T>} */ export class Encoder { /** * @param {T} value */ encode(value) { return new Uint8Array(0) } } /** * @template T * @typedef {import('./interface').Encoder<T>} IEncoder */
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassLeadingOptional.ts
TypeScript
// @allowJs: true // @checkJs: true // @target: es5 // @outDir: ./out // @declaration: true // @filename: bar.js export class Z { f(x = 1, y) { return [x, y]; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassLikeHeuristic.ts
TypeScript
// @allowJs: true // @checkJs: true // @target: es5 // @outDir: ./out // @declaration: true // @filename: index.js // https://github.com/microsoft/TypeScript/issues/35801 let A; A = {}; A.prototype.b = {};
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassMethod.ts
TypeScript
// @allowJs: true // @checkJs: true // @target: esnext // @noImplicitAny: true // @declaration: true // @outDir: out // @Filename: jsDeclarationsClassMethod.js function C1() { /** * A comment prop * @param {number} x * @param {number} y * @returns {number} */ this.prop = function (x, y) { return x + y; } } /** * A comment method * @param {number} x * @param {number} y * @returns {number} */ C1.prototype.method = function (x, y) { return x + y; } /** * A comment staticProp * @param {number} x * @param {number} y * @returns {number} */ C1.staticProp = function (x, y) { return x + y; } class C2 { /** * A comment method1 * @param {number} x * @param {number} y * @returns {number} */ method1(x, y) { return x + y; } } /** * A comment method2 * @param {number} x * @param {number} y * @returns {number} */ C2.prototype.method2 = function (x, y) { return x + y; } /** * A comment staticProp * @param {number} x * @param {number} y * @returns {number} */ C2.staticProp = function (x, y) { return x + y; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassStatic.ts
TypeScript
// @allowJs: true // @checkJs: true // @target: es5 // @outDir: ./out // @declaration: true // @filename: source.js class Handler { static get OPTIONS() { return 1; } process() { } } Handler.statische = function() { } const Strings = { a: "A", b: "B" } module.exports = Handler; module.exports.Strings = Strings /** * @typedef {Object} HandlerOptions * @property {String} name * Should be able to export a type alias at the same time. */
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassStatic2.ts
TypeScript
// @allowJs: true // @checkJs: true // @declaration: true // @emitDeclarationOnly: true // @outDir: ./out/ // @filename: Foo.js class Base { static foo = ""; } export class Foo extends Base {} Foo.foo = "foo"; // @filename: Bar.ts import { Foo } from "./Foo.js"; class Bar extends Foo {} Bar.foo = "foo";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassStaticMethodAugmentation.ts
TypeScript
// @allowJs: true // @checkJs: true // @target: es5 // @outDir: ./out // @declaration: true // @filename: source.js export class Clazz { static method() { } } Clazz.method.prop = 5;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsClasses.ts
TypeScript
// @allowJs: true // @checkJs: true // @target: es5 // @outDir: ./out // @declaration: true // @filename: index.js export class A {} export class B { static cat = "cat"; } export class C { static Cls = class {} } export class D { /** * @param {number} a * @param {number} b */ constructor(a, b) {} } /** * @template T,U */ export class E { /** * @type {T & U} */ field; // @readonly is currently unsupported, it seems - included here just in case that changes /** * @type {T & U} * @readonly */ readonlyField; initializedField = 12; /** * @return {U} */ get f1() { return /** @type {*} */(null); } /** * @param {U} _p */ set f1(_p) {} /** * @return {U} */ get f2() { return /** @type {*} */(null); } /** * @param {U} _p */ set f3(_p) {} /** * @param {T} a * @param {U} b */ constructor(a, b) {} /** * @type {string} */ static staticField; // @readonly is currently unsupported, it seems - included here just in case that changes /** * @type {string} * @readonly */ static staticReadonlyField; static staticInitializedField = 12; /** * @return {string} */ static get s1() { return ""; } /** * @param {string} _p */ static set s1(_p) {} /** * @return {string} */ static get s2() { return ""; } /** * @param {string} _p */ static set s3(_p) {} } /** * @template T,U */ export class F { /** * @type {T & U} */ field; /** * @param {T} a * @param {U} b */ constructor(a, b) {} /** * @template A,B * @param {A} a * @param {B} b */ static create(a, b) { return new F(a, b); } } class G {} export { G }; class HH {} export { HH as H }; export class I {} export { I as II }; export { J as JJ }; export class J {} export class K { constructor() { this.p1 = 12; this.p2 = "ok"; } method() { return this.p1; } } export class L extends K {} export class M extends null { constructor() { this.prop = 12; } } /** * @template T */ export class N extends L { /** * @param {T} param */ constructor(param) { super(); this.another = param; } } /** * @template U * @extends {N<U>} */ export class O extends N { /** * @param {U} param */ constructor(param) { super(param); this.another2 = param; } } var x = /** @type {*} */(null); export class VariableBase extends x {} export class HasStatics { static staticMethod() {} } export class ExtendsStatics extends HasStatics { static also() {} }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassesErr.ts
TypeScript
// @allowJs: true // @checkJs: true // @target: es5 // @outDir: ./out // @declaration: true // @filename: index.js // Pretty much all of this should be an error, (since index signatures and generics are forbidden in js), // but we should be able to synthesize declarations from the symbols regardless export class M<T> { field: T; } export class N<U> extends M<U> { other: U; } export class O { [idx: string]: string; } export class P extends O {} export class Q extends O { [idx: string]: "ok"; } export class R extends O { [idx: number]: "ok"; } export class S extends O { [idx: string]: "ok"; [idx: number]: never; } export class T { [idx: number]: string; } export class U extends T {} export class V extends T { [idx: string]: string; } export class W extends T { [idx: number]: "ok"; } export class X extends T { [idx: string]: string; [idx: number]: "ok"; } export class Y { [idx: string]: {x: number}; [idx: number]: {x: number, y: number}; } export class Z extends Y {} export class AA extends Y { [idx: string]: {x: number, y: number}; } export class BB extends Y { [idx: number]: {x: 0, y: 0}; } export class CC extends Y { [idx: string]: {x: number, y: number}; [idx: number]: {x: 0, y: 0}; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsCommonjsRelativePath.ts
TypeScript
// @checkJs: true // @declaration: true // @emitDeclarationOnly: true // @module: commonjs // @Filename: thing.js 'use strict'; class Thing {} module.exports = { Thing } // @Filename: reexport.js 'use strict'; const Thing = require('./thing').Thing module.exports = { Thing }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/jsDeclarationsComputedNames.ts
TypeScript
// @allowJs: true // @checkJs: true // @target: es5 // @lib: es6 // @outDir: ./out // @declaration: true // @filename: index.js const TopLevelSym = Symbol(); const InnerSym = Symbol(); module.exports = { [TopLevelSym](x = 12) { return x; }, items: { [InnerSym]: (arg = {x: 12}) => arg.x } } // @filename: index2.js const TopLevelSym = Symbol(); const InnerSym = Symbol(); export class MyClass { static [TopLevelSym] = 12; [InnerSym] = "ok"; /** * @param {typeof TopLevelSym | typeof InnerSym} _p */ constructor(_p = InnerSym) { // switch on _p } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University