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/spreadUnion3.ts
TypeScript
// @strictNullChecks: true function f(x: { y: string } | undefined): { y: string } { return { y: 123, ...x } // y: string | number } f(undefined) function g(t?: { a: number } | null): void { let b = { ...t }; let c: number = b.a; // might not have 'a' } g() g(undefined) g(null) // spreading nothing but ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/spreadUnion4.ts
TypeScript
declare const a: { x: () => void } declare const b: { x?: () => void } const c = { ...a, ...b };
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticAndNonStaticPropertiesSameName.ts
TypeScript
class C { x: number; static x: number; f() { } static f() { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticAutoAccessors.ts
TypeScript
// @target: es2022,es2017 // @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/53752 class A { // uses class reference static accessor x = 1; // uses 'this' accessor y = 2; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticAutoAccessorsWithDecorators.ts
TypeScript
// @target: es2022,es2017 // @noTypesAndSymbols: true // https://github.com/microsoft/TypeScript/issues/53752 class A { // uses class reference @((t, c) => {}) static accessor x = 1; // uses 'this' @((t, c) => {}) accessor y = 2; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticFactory1.ts
TypeScript
class Base { foo() { return 1; } static create() { return new this(); } } class Derived extends Base { foo() { return 2; } } var d = Derived.create(); d.foo();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticIndexSignature1.ts
TypeScript
class C { static [s: string]: number; static [s: number]: 42 } C["foo"] = 1 C.bar = 2; const foo = C["foo"] C[42] = 42 C[2] = 2; const bar = C[42]
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticIndexSignature2.ts
TypeScript
class C { static readonly [s: string]: number; static readonly [s: number]: 42 } C["foo"] = 1 C.bar = 2; const foo = C["foo"] C[42] = 42 C[2] = 2; const bar = C[42]
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticIndexSignature3.ts
TypeScript
// @strict: true class B { static readonly [s: string]: number; static readonly [s: number]: 42 | 233 } class D extends B { static readonly [s: string]: number } class ED extends D { static readonly [s: string]: boolean static readonly [s: number]: 1 } class DD extends D { static readonly [...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticIndexSignature6.ts
TypeScript
// @strict: true function foo () { return class<T> { static [s: string]: number static [s: number]: 42 foo(v: T) { return v } } } const C = foo() C.a; C.a = 1; C[2]; C[2] = 42; const c = new C<number>(); c.foo(1);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticIndexSignature7.ts
TypeScript
// @strict: true class X { static [index: string]: string; static x = 12; // Should error, incompatible with index signature } class Y { static [index: string]: string; static foo() {} // should error, incompatible with index signature }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticIndexers.ts
TypeScript
// static indexers not allowed class C { static [x: string]: string; } class D { static [x: number]: string; } class E<T> { static [x: string]: T; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticMemberAssignsToConstructorFunctionMembers.ts
TypeScript
class C { static foo() { C.foo = () => { } } static bar(x: number): number { C.bar = () => { } // error C.bar = (x) => x; // ok C.bar = (x: number) => 1; // ok return 1; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticMemberInitialization.ts
TypeScript
class C { static x = 1; } var c = new C(); var r = C.x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticMembersUsingClassTypeParameter.ts
TypeScript
// BUG 745747 class C<T> { static x: T; static f(x: T) {} } class C2<T, U> { static x: U; static f(x: U) { } } class C3<T extends Date> { static x: T; static f(x: T) { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticPropertyAndFunctionWithSameName.ts
TypeScript
class C { static f: number; f: number; } class D { static f: number; f() { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticPropertyNameConflictsInAmbientContext.ts
TypeScript
//@Filename: decl.d.ts // name declare class StaticName { static name: number; // ok name: string; // ok } declare class StaticNameFn { static name(): string; // ok name(): string; // ok } // length declare class StaticLength { static length: number; // ok length: string; // ok } declare cla...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/staticPropertyNotInClassType.ts
TypeScript
module NonGeneric { class C { fn() { return this; } static get x() { return 1; } static set x(v) { } constructor(public a: number, private b: number) { } static foo: string; // not reflected in class type } module C { export var bar = ''; // not reflected in ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/strictBindCallApply1.ts
TypeScript
// @strict: true declare function foo(a: number, b: string): string; declare function overloaded(s: string): number; declare function overloaded(n: number): string; declare function generic<T>(x: T): T; let f00 = foo.bind(undefined); let f01 = foo.bind(undefined, 10); let f02 = foo.bind(undefined, 10, "hello"); let...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/strictBindCallApply2.ts
TypeScript
// @strictFunctionTypes: false // @strictBindCallApply: true // Repro from #32964 interface Foo { blub: string }; function fn(this: Foo) {} type Test = ThisParameterType<typeof fn>; const fb = fn.bind({ blub: "blub" });
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/strictNullChecksNoWidening.ts
TypeScript
// @strictNullChecks: true var a1 = null; var a2 = undefined; var a3 = void 0; var b1 = []; var b2 = [,]; var b3 = [undefined]; var b4 = [[], []]; var b5 = [[], [,]]; declare function f<T>(x: T): T; var c1 = f(null); var c2 = f(undefined); var c3 = f([]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/strictPropertyInitialization.ts
TypeScript
// @strict: true // @target: es2015 // @declaration: true // Properties with non-undefined types require initialization class C1 { a: number; // Error b: number | undefined; c: number | null; // Error d?: number; #f: number; //Error #g: number | undefined; #h: number | null; //Error ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/strictTupleLength.ts
TypeScript
var t0: []; var t1: [number]; var t2: [number, number]; var arr: number[]; var len0: 0 = t0.length; var len1: 1 = t1.length; var len2: 2 = t2.length; var lena: number = arr.length; var t1 = t2; // error var t2 = t1; // error type A<T extends any[]> = T['length']; var b: A<[boolean]>; var c: 1 = b; t1 = arr; // erro...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringEnumInElementAccess01.ts
TypeScript
// @noImplicitAny: true enum E { A = "a", B = "b", C = "c", } interface Item { a: string; b: number; c: boolean; } declare const item: Item; declare const e: E; const snb: string | number | boolean = item[e];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringEnumLiteralTypes1.ts
TypeScript
const enum Choice { Unknown = "", Yes = "yes", No = "no" }; type YesNo = Choice.Yes | Choice.No; type NoYes = Choice.No | Choice.Yes; type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No; function f1() { var a: YesNo; var a: NoYes; var a: Choice.Yes | Choice.No; var a: Choice.No | Choice.Yes; }...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringEnumLiteralTypes2.ts
TypeScript
// @strictNullChecks: true const enum Choice { Unknown = "", Yes = "yes", No = "no" }; type YesNo = Choice.Yes | Choice.No; type NoYes = Choice.No | Choice.Yes; type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No; function f1() { var a: YesNo; var a: NoYes; var a: Choice.Yes | Choice.No; var ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringEnumLiteralTypes3.ts
TypeScript
const enum Choice { Unknown = "", Yes = "yes", No = "no" }; type Yes = Choice.Yes; type YesNo = Choice.Yes | Choice.No; type NoYes = Choice.No | Choice.Yes; type UnknownYesNo = Choice.Unknown | Choice.Yes | Choice.No; function f1(a: Yes, b: YesNo, c: UnknownYesNo, d: Choice) { a = a; a = b; a = c; a =...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringIndexerConstrainsPropertyDeclarations.ts
TypeScript
// String indexer types constrain the types of named properties in their containing type interface MyString extends String { foo: number; } class C { [x: string]: string; constructor() { } // ok a: string; // ok b: number; // error c: () => {} // error "d": string; // ok "e": number;...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringIndexerConstrainsPropertyDeclarations2.ts
TypeScript
// String indexer providing a constraint of a user defined type class A { foo(): string { return ''; } } class B extends A { bar(): string { return ''; } } class Foo { [x: string]: A; a: A; // ok b: B; // ok c: number; // error d: string; // error } interface Foo2 { [x: string]: A; ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringIndexingResults.ts
TypeScript
class C { [x: string]: string; y = ''; } var c: C; var r1 = c['y']; var r2 = c['a']; var r3 = c[1]; interface I { [x: string]: string; y: string; } var i: I var r4 = i['y']; var r5 = i['a']; var r6 = i[1]; var a: { [x: string]: string; y: string; } var r7 = a['y']; var r8 = a['a']; var r...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralCheckedInIf01.ts
TypeScript
 type S = "a" | "b"; type T = S[] | S; function f(foo: T) { if (foo === "a") { return foo; } else if (foo === "b") { return foo; } else { return (foo as S[])[0]; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralCheckedInIf02.ts
TypeScript
 type S = "a" | "b"; type T = S[] | S; function isS(t: T): t is S { return t === "a" || t === "b"; } function f(foo: T) { if (isS(foo)) { return foo; } else { return foo[0]; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralMatchedInSwitch01.ts
TypeScript
 type S = "a" | "b"; type T = S[] | S; var foo: T; switch (foo) { case "a": case "b": break; default: foo = (foo as S[])[0]; break; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralType.ts
TypeScript
var x: 'hi'; function f(x: 'hi'); function f(x: string); function f(x: any) { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypeAssertion01.ts
TypeScript
 type S = "a" | "b"; type T = S[] | S; var s: S; var t: T; var str: string; //////////////// s = <S>t; s = t as S; s = <S>str; s = str as S; //////////////// t = <T>s; t = s as T; t = <T>str; t = str as T; //////////////// str = <string>s; str = s as string; str = <string>t; str = t as string;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypeIsSubtypeOfString.ts
TypeScript
// string literal types are subtypes of string, any // ok function f1(x: 'a'); function f1(x: string); function f1(x: string) { } // ok function f2(x: 'a'); function f2(x: any); function f2(x: any) { } // errors function f3(x: 'a'); function f3(x: Object); function f3(x: any) { } function f4(x: 'a'); function f4(x:...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesAndLogicalOrExpressions01.ts
TypeScript
// @declaration: true declare function myRandBool(): boolean; let a: "foo" = "foo"; let b = a || "foo"; let c: "foo" = b; let d = b || "bar"; let e: "foo" | "bar" = d;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesAndParenthesizedExpressions01.ts
TypeScript
// @declaration: true declare function myRandBool(): boolean; let a: "foo" = ("foo"); let b: "foo" | "bar" = ("foo"); let c: "foo" = (myRandBool ? "foo" : ("foo")); let d: "foo" | "bar" = (myRandBool ? "foo" : ("bar"));
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesAndTuples01.ts
TypeScript
// @declaration: true // Should all be strings. let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; type RexOrRaptor = "t-rex" | "raptor" let [im, a, dinosaur]: ["I'm", "a", RexOrRaptor] = ['I\'m', 'a', 't-rex']; rawr(dinosaur); function rawr(dino: RexOrRaptor) { if (dino === "t-rex") { ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesAsTags01.ts
TypeScript
// @declaration: true type Kind = "A" | "B" interface Entity { kind: Kind; } interface A extends Entity { kind: "A"; a: number; } interface B extends Entity { kind: "B"; b: string; } function hasKind(entity: Entity, kind: "A"): entity is A; function hasKind(entity: Entity, kind: "B"): entity is...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesAsTags02.ts
TypeScript
// @declaration: true type Kind = "A" | "B" interface Entity { kind: Kind; } interface A extends Entity { kind: "A"; a: number; } interface B extends Entity { kind: "B"; b: string; } function hasKind(entity: Entity, kind: "A"): entity is A; function hasKind(entity: Entity, kind: "B"): entity is...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesAsTags03.ts
TypeScript
// @declaration: true type Kind = "A" | "B" interface Entity { kind: Kind; } interface A extends Entity { kind: "A"; a: number; } interface B extends Entity { kind: "B"; b: string; } // Currently (2015-12-14), we write '"A" | "A"' and '"B" | "B"' to avoid // interpreting respective overloads as...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesAsTypeParameterConstraint01.ts
TypeScript
// @declaration: true function foo<T extends "foo">(f: (x: T) => T) { return f; } function bar<T extends "foo" | "bar">(f: (x: T) => T) { return f; } let f = foo(x => x); let fResult = f("foo"); let g = foo((x => x)); let gResult = g("foo"); let h = bar(x => x); let hResult = h("foo"); hResult = h("bar");
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesAsTypeParameterConstraint02.ts
TypeScript
// @declaration: true function foo<T extends "foo">(f: (x: T) => T) { return f; } let f = foo((y: "foo" | "bar") => y === "foo" ? y : "foo"); let fResult = f("foo");
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesInImplementationSignatures.ts
TypeScript
// String literal types are only valid in overload signatures function foo(x: 'hi') { } var f = function foo(x: 'hi') { } var f2 = (x: 'hi', y: 'hi') => { } class C { foo(x: 'hi') { } } interface I { (x: 'hi'); foo(x: 'hi', y: 'hi'); } var a: { (x: 'hi'); foo(x: 'hi'); } var b = { foo(x: 'h...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesInImplementationSignatures2.ts
TypeScript
// String literal types are only valid in overload signatures function foo(x: any); function foo(x: 'hi') { } class C { foo(x: string); foo(x: 'hi') { } } interface I { (x: 'a'); (x: 'hi'); foo(x: 'a', y: 'a'); foo(x: 'hi', y: 'hi'); } var a: { (x: 'hi'); (x: 'a'); foo(x: 'hi'); ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesInUnionTypes01.ts
TypeScript
// @declaration: true type T = "foo" | "bar" | "baz"; var x: "foo" | "bar" | "baz" = undefined; var y: T = undefined; if (x === "foo") { let a = x; } else if (x !== "bar") { let b = x || y; } else { let c = x; let d = y; let e: (typeof x) | (typeof y) = c || d; } x = y; y = x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesInUnionTypes02.ts
TypeScript
// @declaration: true type T = string | "foo" | "bar" | "baz"; var x: "foo" | "bar" | "baz" | string = undefined; var y: T = undefined; if (x === "foo") { let a = x; } else if (x !== "bar") { let b = x || y; } else { let c = x; let d = y; let e: (typeof x) | (typeof y) = c || d; } x = y; y = x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesInUnionTypes03.ts
TypeScript
// @declaration: true type T = number | "foo" | "bar"; var x: "foo" | "bar" | number; var y: T = undefined; if (x === "foo") { let a = x; } else if (x !== "bar") { let b = x || y; } else { let c = x; let d = y; let e: (typeof x) | (typeof y) = c || d; } x = y; y = x;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesInUnionTypes04.ts
TypeScript
// @declaration: true type T = "" | "foo"; let x: T = undefined; let y: T = undefined; if (x === "") { let a = x; } if (x !== "") { let b = x; } if (x == "") { let c = x; } if (x != "") { let d = x; } if (x) { let e = x; } if (!x) { let f = x; } if (!!x) { let g = x; } if (!!!x) { ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesOverloadAssignability01.ts
TypeScript
// @declaration: true function f(x: "foo"): number; function f(x: string): number { return 0; } function g(x: "bar"): number; function g(x: string): number { return 0; } let a = f; let b = g; a = b; b = a;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesOverloadAssignability02.ts
TypeScript
// @declaration: true function f(x: "foo"): number; function f(x: "foo"): number { return 0; } function g(x: "bar"): number; function g(x: "bar"): number { return 0; } let a = f; let b = g; a = b; b = a;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesOverloadAssignability03.ts
TypeScript
// @declaration: true function f(x: "foo"): number; function f(x: string): number { return 0; } function g(x: "foo"): number; function g(x: string): number { return 0; } let a = f; let b = g; a = b; b = a;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesOverloadAssignability04.ts
TypeScript
// @declaration: true function f(x: "foo"): number; function f(x: "foo"): number { return 0; } function g(x: "foo"): number; function g(x: "foo"): number { return 0; } let a = f; let b = g; a = b; b = a;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesOverloadAssignability05.ts
TypeScript
// @declaration: true function f(x: "foo"): number; function f(x: string): number; function f(x: string): number { return 0; } function g(x: "foo"): number; function g(x: string): number { return 0; } let a = f; let b = g; a = b; b = a;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesOverloads01.ts
TypeScript
// @declaration: true type PrimitiveName = 'string' | 'number' | 'boolean'; function getFalsyPrimitive(x: "string"): string; function getFalsyPrimitive(x: "number"): number; function getFalsyPrimitive(x: "boolean"): boolean; function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; function getFalsyPrimi...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesOverloads02.ts
TypeScript
// @declaration: true function getFalsyPrimitive(x: "string"): string; function getFalsyPrimitive(x: "number"): number; function getFalsyPrimitive(x: "boolean"): boolean; function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; functi...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesOverloads03.ts
TypeScript
// @declaration: true interface Base { x: string; y: number; } interface HelloOrWorld extends Base { p1: boolean; } interface JustHello extends Base { p2: boolean; } interface JustWorld extends Base { p3: boolean; } let hello: "hello"; let world: "world"; let helloOrWorld: "hello" | "world"; ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesOverloads04.ts
TypeScript
// @declaration: true declare function f(x: (p: "foo" | "bar") => "foo"); f(y => { const z = y = "foo"; return z; })
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesOverloads05.ts
TypeScript
// @declaration: true interface Animal { animal: {} }; interface Dog extends Animal { dog: {} } interface Cat extends Animal { cat: {} } interface Moose extends Animal { moose: {} } function doThing(x: "dog"): Dog; function doThing(x: "cat"): Cat; function doThing(x: string): Animal; function doThing(x: string, y?: ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesTypePredicates01.ts
TypeScript
// @declaration: true type Kind = "A" | "B" function kindIs(kind: Kind, is: "A"): kind is "A"; function kindIs(kind: Kind, is: "B"): kind is "B"; function kindIs(kind: Kind, is: Kind): boolean { return kind === is; } var x: Kind = undefined; if (kindIs(x, "A")) { let a = x; } else { let b = x; } if (!k...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesWithTemplateStrings01.ts
TypeScript
// @declaration: true let ABC: "ABC" = `ABC`; let DE_NEWLINE_F: "DE\nF" = `DE F`; let G_QUOTE_HI: 'G"HI'; let JK_BACKTICK_L: "JK`L" = `JK\`L`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesWithTemplateStrings02.ts
TypeScript
// @declaration: true let abc: "AB\r\nC" = `AB C`; let de_NEWLINE_f: "DE\nF" = `DE${"\n"}F`;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesWithVariousOperators01.ts
TypeScript
// @declaration: true let abc: "ABC" = "ABC"; let xyz: "XYZ" = "XYZ"; let abcOrXyz: "ABC" | "XYZ" = abc || xyz; let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; let a = "" + abc; let b = abc + ""; let c = 10 + abc; let d = abc + 10; let e = xyz + abc; let f = abc + xyz; let g = true + abc; let h = abc...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralTypesWithVariousOperators02.ts
TypeScript
// @declaration: true let abc: "ABC" = "ABC"; let xyz: "XYZ" = "XYZ"; let abcOrXyz: "ABC" | "XYZ" = abc || xyz; let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; let a = abcOrXyzOrNumber + 100; let b = 100 + abcOrXyzOrNumber; let c = abcOrXyzOrNumber + abcOrXyzOrNumber; let d = abcOrXyzOrNumber + true;...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralsAssertionsInEqualityComparisons01.ts
TypeScript
var a = "foo" === "bar" as string; var b = "foo" !== ("bar" as string); var c = "foo" == (<any>"bar");
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralsAssertionsInEqualityComparisons02.ts
TypeScript
type EnhancedString = string & { enhancements: any }; var a = "foo" === "bar" as "baz"; var b = "foo" !== ("bar" as "foo"); var c = "foo" == (<number>"bar"); var d = "foo" === ("bar" as EnhancedString);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralsAssignedToStringMappings.ts
TypeScript
declare var x: Uppercase<Lowercase<string>>; // good x = "A"; // bad x = "a"; declare var y: Uppercase<Lowercase<`${number}`>>; // good y = "1"; // bad y = "a"; y = "A";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralsWithEqualityChecks01.ts
TypeScript
let x: "foo"; let y: "foo" | "bar"; let b: boolean; b = x === y; b = "foo" === y b = y === "foo"; b = "foo" === "bar"; b = "bar" === x; b = x === "bar"; b = y === "bar"; b = "bar" === y; b = x !== y; b = "foo" !== y b = y !== "foo"; b = "foo" !== "bar"; b = "bar" !== x; b = x !== "bar"; b = y !== "bar"; b = "bar" !=...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralsWithEqualityChecks02.ts
TypeScript
let x: "foo"; let y: "foo" | "bar"; let b: boolean; b = x == y; b = "foo" == y b = y == "foo"; b = "foo" == "bar"; b = "bar" == x; b = x == "bar"; b = y == "bar"; b = "bar" == y; b = x != y; b = "foo" != y b = y != "foo"; b = "foo" != "bar"; b = "bar" != x; b = x != "bar"; b = y != "bar"; b = "bar" != y;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralsWithEqualityChecks03.ts
TypeScript
interface Runnable { isRunning: boolean; } interface Refrigerator extends Runnable { makesFoodGoBrrr: boolean; } let x: string; let y: "foo" | Refrigerator; let b: boolean; b = x === y; b = "foo" === y b = y === "foo"; b = "foo" === "bar"; b = "bar" === x; b = x === "bar"; b = y === "bar"; b = "bar" === y; ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralsWithEqualityChecks04.ts
TypeScript
interface Runnable { isRunning: boolean; } interface Refrigerator extends Runnable { makesFoodGoBrrr: boolean; } let x: string; let y: "foo" | Refrigerator; let b: boolean; b = x == y; b = "foo" == y b = y == "foo"; b = "foo" == "bar"; b = "bar" == x; b = x == "bar"; b = y == "bar"; b = "bar" == y; b = x !...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralsWithSwitchStatements01.ts
TypeScript
let x: "foo"; let y: "foo" | "bar"; switch (x) { case "foo": break; case "bar": break; case y: y; break; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralsWithSwitchStatements02.ts
TypeScript
let x: "foo"; let y: "foo" | "bar"; let b: boolean; b = x == y; b = "foo" == y b = y == "foo"; b = "foo" == "bar"; b = x != y; b = "foo" != y b = y != "foo"; b = "foo" != "bar";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralsWithSwitchStatements03.ts
TypeScript
let x: "foo"; let y: "foo" | "bar"; let z: "bar"; declare function randBool(): boolean; switch (x) { case randBool() ? "foo" : "baz": break; case (randBool() ? ("bar") : "baz" ? "bar" : "baz"): break; case (("bar")): break; case (x, y, ("baz")): x; y; ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralsWithSwitchStatements04.ts
TypeScript
let x: "foo"; let y: "foo" | "bar"; declare function randBool(): boolean; switch (y) { case "foo", x: break; case x, "foo": break; case x, "baz": break; case "baz", x: break; case "baz" && "bar": break; case "baz" && ("foo" || "bar"): break; ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringLiteralsWithTypeAssertions01.ts
TypeScript
let fooOrBar: "foo" | "bar"; let a = "foo" as "bar"; let b = "bar" as "foo"; let c = fooOrBar as "foo"; let d = fooOrBar as "bar"; let e = fooOrBar as "baz"; let f = "baz" as typeof fooOrBar;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringMappingDeferralInConditionalTypes.ts
TypeScript
// @strict: true // @noEmit: true // https://github.com/microsoft/TypeScript/issues/55847 type A<S> = Lowercase<S & string> extends "foo" ? 1 : 0; let x1: A<"foo"> = 1; // ok type B<S> = Lowercase<S & string> extends `f${string}` ? 1 : 0; let x2: B<"foo"> = 1; // ok type C<S> = Capitalize<Lowercase<S & string>> ext...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringMappingOverPatternLiterals.ts
TypeScript
// non-template type A = "aA"; type B = Uppercase<A>; type C = Lowercase<A>; // templated type ATemplate = `aA${string}`; type BTemplate = Uppercase<ATemplate>; type CTemplate = Lowercase<ATemplate>; function f1( a: A, b: B, c: C, a_template: ATemplate, b_template: BTemplate, c_template: CTemp...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringMappingReduction.ts
TypeScript
// @strict: true // @noEmit: true type T00 = "prop" | `p${Lowercase<string>}p`; // `p${Lowercase<string>}p` type T01 = "prop" | Lowercase<string>; // Lowercase<string> type T02 = "PROP" | Lowercase<string>; // "PROP" | Lowercase<string> type T10 = "prop" & `p${Lowercase<string>}p`; // "prop" type T11 = "prop" & L...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringNamedPropertyAccess.ts
TypeScript
class C { "a b": number; static "c d": number; } var c: C; var r1 = c["a b"]; var r1b = C['c d']; interface I { "a b": number; } var i: I; var r2 = i["a b"]; var a: { "a b": number; } var r3 = a["a b"]; var b = { "a b": 1 } var r4 = b["a b"];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringPropertyAccess.ts
TypeScript
var x = ''; var a = x.charAt(0); var b = x.hasOwnProperty('charAt'); var c = x['charAt'](0); var e = x['hasOwnProperty']('toFixed');
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/stringPropertyAccessWithError.ts
TypeScript
var x = ''; var d = x['charAt']('invalid'); // error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypesOfAny.ts
TypeScript
// every type is a subtype of any, no errors expected interface I { [x: string]: any; foo: any; } interface I2 { [x: string]: any; foo: number; } interface I3 { [x: string]: any; foo: string; } interface I4 { [x: string]: any; foo: boolean; } interface I5 { [x: string]: any;...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypesOfTypeParameter.ts
TypeScript
// checking whether other types are subtypes of type parameters class C3<T> { foo: T; } class D1<T, U> extends C3<T> { foo: U; // error } function f1<T, U>(x: T, y: U) { var r = true ? x : y; // error var r = true ? y : x; // error } interface I1 { foo: number; } class C1 { foo: number; } class C2<T...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypesOfTypeParameterWithConstraints.ts
TypeScript
// checking whether other types are subtypes of type parameters with constraints class C3<T> { foo: T; } class D1<T extends U, U> extends C3<T> { [x: string]: T; foo: T; // ok } class D2<T extends U, U> extends C3<U> { [x: string]: U; foo: T; // ok } class D3<T extends U, U> extends C3<T> { ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypesOfTypeParameterWithConstraints2.ts
TypeScript
// checking whether other types are subtypes of type parameters with constraints function f1<T extends U, U>(x: T, y: U) { var r = true ? x : y; var r = true ? y : x; } // V > U > T function f2<T extends U, U extends V, V>(x: T, y: U, z: V) { var r = true ? x : y; var r = true ? y : x; // ok ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypesOfTypeParameterWithConstraints3.ts
TypeScript
// checking whether other types are subtypes of type parameters with constraints function f<T extends U, U, V>(t: T, u: U, v: V) { // ok var r = true ? t : u; var r = true ? u : t; // ok var r2 = true ? t : v; var r2 = true ? v : t; // ok var r3 = true ? v : u; var r3 = true ? u :...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypesOfTypeParameterWithConstraints4.ts
TypeScript
// checking whether other types are subtypes of type parameters with constraints class Foo { foo: number; } function f<T extends Foo, U extends Foo, V>(t: T, u: U, v: V) { // ok var r = true ? t : u; var r = true ? u : t; // ok var r2 = true ? t : v; var r2 = true ? v : t; // ok var r...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypesOfTypeParameterWithRecursiveConstraints.ts
TypeScript
// checking whether other types are subtypes of type parameters with constraints class Foo<T> { foo: T; } function f<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>>(t: T, u: U, v: V) { // ok var r1 = true ? t : u; var r1 = true ? u : t; // ok var r2 = true ? t : v; var r2 = true ? v : t;...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypesOfUnion.ts
TypeScript
enum E { e1, e2 } interface I8 { [x: string]: number[]; } class A { foo: number; } class A2<T> { foo: T; } function f() { } module f { export var bar = 1; } class c { baz: string } module c { export var bar = 1; } // A type T is a subtype of a union type U if T is a subtype of any type in U. interface I1<T> { [x: ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithCallSignatures.ts
TypeScript
module CallSignature { declare function foo1(cb: (x: number) => void): typeof cb; declare function foo1(cb: any): any; var r = foo1((x: number) => 1); // ok because base returns void var r2 = foo1(<T>(x: T) => ''); // ok because base returns void declare function foo2(cb: (x: number, y: number) => ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithCallSignatures2.ts
TypeScript
// checking subtype relations for function types as it relates to contextual signature instantiation class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } class OtherDerived extends Base { bing: string; } declare function foo1(a: (x: number) => number[...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithCallSignatures3.ts
TypeScript
// checking subtype relations for function types as it relates to contextual signature instantiation // error cases, so function calls will all result in 'any' module Errors { class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } class O...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithCallSignatures4.ts
TypeScript
// checking subtype relations for function types as it relates to contextual signature instantiation class Base { foo: string; } class Derived extends Base { bar: string; } class Derived2 extends Derived { baz: string; } class OtherDerived extends Base { bing: string; } declare function foo1(a: <T>(x: T) => T[]); dec...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithCallSignaturesA.ts
TypeScript
declare function foo3(cb: (x: number) => number): typeof cb; var r5 = foo3((x: number) => ''); // error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithCallSignaturesWithOptionalParameters.ts
TypeScript
// call signatures in derived types must have the same or fewer optional parameters as the base type interface Base { a: () => number; a2: (x?: number) => number; a3: (x: number) => number; a4: (x: number, y?: number) => number; a5: (x?: number, y?: number) => number; } interface I1 extends Base ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithCallSignaturesWithRestParameters.ts
TypeScript
// call signatures in derived types must have the same or fewer optional parameters as the base type interface Base { a: (...args: number[]) => number; a2: (x: number, ...z: number[]) => number; a3: (x: number, y?: string, ...z: number[]) => number; a4: (x?: number, y?: string, ...z: number[]) => numb...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithCallSignaturesWithSpecializedSignatures.ts
TypeScript
// same as subtypingWithCallSignatures but with additional specialized signatures that should not affect the results module CallSignature { interface Base { // T // M's (x: 'a'): void; (x: string, y: number): void; } // S's interface I extends Base { // N's (x: ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/subtypingWithConstructSignatures.ts
TypeScript
module ConstructSignature { declare function foo1(cb: new (x: number) => void): typeof cb; declare function foo1(cb: any): any; var rarg1: new (x: number) => number; var r = foo1(rarg1); // ok because base returns void var rarg2: new <T>(x: T) => string; var r2 = foo1(rarg2); // ok because base ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University