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/forInContinueStatements.ts | TypeScript | // @allowUnusedLabels: true
for(var x in {}) {
continue;
}
ONE:
for(var x in {}) {
continue ONE;
}
TWO:
THREE:
for(var x in {}) {
continue THREE;
}
FOUR:
for(var x in {}) {
FIVE:
for(var x in {}) {
continue FOUR;
}
}
for(var x in {}) {
SIX:
for(var x in {}) continue SIX;
}
SEVEN:
for (var x in {}) for (var x in {}) for (var x in {}) continue SEVEN;
EIGHT:
for (var x in {}){
var fn = function () { }
continue EIGHT;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/forStatements.ts | TypeScript | // @allowUnreachableCode: true
interface I {
id: number;
}
class C implements I {
id: number;
}
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(); }
}
for(var aNumber: number = 9.9;;){}
for(var aString: string = 'this is a string';;){}
for(var aDate: Date = new Date(12);;){}
for(var anObject: Object = new Object();;){}
for(var anAny: any = null;;){}
for(var aSecondAny: any = undefined;;){}
for(var aVoid: void = undefined;;){}
for(var anInterface: I = new C();;){}
for(var aClass: C = new C();;){}
for(var aGenericClass: D<string> = new D<string>();;){}
for(var anObjectLiteral: I = { id: 12 };;){}
for(var anOtherObjectLiteral: { id: number } = new C();;){}
for(var aFunction: typeof F = F;;){}
for(var anOtherFunction: (x: string) => number = F;;){}
for(var aLambda: typeof F = (x) => 2;;){}
for(var aModule: typeof M = M;;){}
for(var aClassInModule: M.A = new M.A();;){}
for(var aFunctionInModule: typeof M.F2 = (x) => 'this is a string';;){} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/forStatementsMultipleInvalidDecl.ts | TypeScript | // @allowUnreachableCode: true
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
for( var a: any;;){}
for( var a = 1;;){}
for( var a = 'a string';;){}
for( var a = new C();;){}
for( var a = new D<string>();;){}
for( var a = M;;){}
for( var b: I;;){}
for( var b = new C();;){}
for( var b = new C2();;){}
for(var f = F;;){}
for( var f = (x: number) => '';;){}
for(var arr: string[];;){}
for( var arr = [1, 2, 3, 4];;){}
for( var arr = [new C(), new C2(), new D<string>()];;){}
for(var arr2 = [new D<string>()];;){}
for( var arr2 = new Array<D<number>>();;){}
for(var m: typeof M;;){}
for( var m = M.A;;){} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/forStatementsMultipleValidDecl.ts | TypeScript | // @allowUnreachableCode: true
// all expected to be valid
for (var x: number; ;) { }
for (var x = 2; ;) { }
for (var x = <number>undefined; ;) { }
// new declaration space, making redeclaring x as a string valid
function declSpace() {
for (var x = 'this is a string'; ;) { }
}
interface Point { x: number; y: number; }
for (var p: Point; ;) { }
for (var p = { x: 1, y: 2 }; ;) { }
for (var p: Point = { x: 0, y: undefined }; ;) { }
for (var p = { x: 1, y: <number>undefined }; ;) { }
for (var p: { x: number; y: number; } = { x: 1, y: 2 }; ;) { }
for (var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; ;) { }
for (var p: typeof p; ;) { }
for (var fn = function (s: string) { return 42; }; ;) { }
for (var fn = (s: string) => 3; ;) { }
for (var fn: (s: string) => number; ;) { }
for (var fn: { (s: string): number }; ;) { }
for (var fn = <(s: string) => number> null; ;) { }
for (var fn: typeof fn; ;) { }
for (var a: string[]; ;) { }
for (var a = ['a', 'b']; ;) { }
for (var a = <string[]>[]; ;) { }
for (var a: string[] = []; ;) { }
for (var a = new Array<string>(); ;) { }
for (var a: typeof a; ;) { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/forgottenNew.ts | TypeScript | module Tools {
export class NullLogger { }
}
var logger = Tools.NullLogger(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionCalls.ts | TypeScript |
// Invoke function call on value of type 'any' with no type arguments
var anyVar: any;
anyVar(0);
anyVar('');
// Invoke function call on value of type 'any' with type arguments
// These should be errors
anyVar<string>('hello');
anyVar<number>();
anyVar<Window>(undefined);
// Invoke function call on value of a subtype of Function with no call signatures with no type arguments
interface SubFunc extends Function {
prop: number;
}
var subFunc: SubFunc;
subFunc(0);
subFunc('');
subFunc();
// Invoke function call on value of a subtype of Function with no call signatures with type arguments
// These should be errors
subFunc<number>(0);
subFunc<string>('');
subFunc<any>();
// Invoke function call on value of type Function with no call signatures with type arguments
// These should be errors
var func: Function;
func<number>(0);
func<string>('');
func<any>();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionConstraintSatisfaction.ts | TypeScript | // satisfaction of a constraint to Function, no errors expected
function foo<T extends Function>(x: T): T { return x; }
interface I {
(): string;
}
var i: I;
class C {
foo: string;
}
var a: { (): string };
var b: { new (): string };
var c: { (): string; (x): string };
var r = foo(new Function());
var r1 = foo((x) => x);
var r2 = foo((x: string[]) => x);
var r3 = foo(function (x) { return x });
var r4 = foo(function (x: string[]) { return x });
var r5 = foo(i);
var r6 = foo(C);
var r7 = foo(b);
var r8 = foo(c);
interface I2<T> {
(x: T): T;
}
var i2: I2<string>;
class C2<T> {
foo: T;
}
var a2: { <T>(x: T): T };
var b2: { new <T>(x: T): T };
var c2: { <T>(x: T): T; <T>(x: T, y: T): T };
var r9 = foo(<U>(x: U) => x);
var r10 = foo(function <U>(x: U) { return x; });
var r11 = foo(<U extends Date>(x: U) => x);
var r12 = foo(<U, V>(x: U, y: V) => x);
var r13 = foo(i2);
var r14 = foo(C2);
var r15 = foo(b2);
var r16 = foo(c2);
interface F2 extends Function { foo: string; }
var f2: F2;
var r17 = foo(f2);
function foo2<T extends { (): void }, U extends { (): void }>(x: T, y: U) {
foo(x);
foo(y);
}
//function foo2<T extends { (): void }, U extends T>(x: T, y: U) {
// foo(x);
// foo(y);
//} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionConstraintSatisfaction2.ts | TypeScript | // satisfaction of a constraint to Function, all of these invocations are errors unless otherwise noted
function foo<T extends Function>(x: T): T { return x; }
foo(1);
foo(() => { }, 1);
foo(1, () => { });
function foo2<T extends (x: string) => string>(x: T): T { return x; }
class C {
foo: string;
}
var b: { new (x: string): string };
class C2<T> {
foo: T;
}
var b2: { new <T>(x: T): T };
var r = foo2(new Function());
var r2 = foo2((x: string[]) => x);
var r6 = foo2(C);
var r7 = foo2(b);
var r8 = foo2(<U>(x: U) => x); // no error expected
var r11 = foo2(<U, V>(x: U, y: V) => x);
var r13 = foo2(C2);
var r14 = foo2(b2);
interface F2 extends Function { foo: string; }
var f2: F2;
var r16 = foo2(f2);
function fff<T extends { (): void }, U extends T>(x: T, y: U) {
foo2(x);
foo2(y);
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionConstraintSatisfaction3.ts | TypeScript | // satisfaction of a constraint to Function, no errors expected
function foo<T extends (x: string) => string>(x: T): T { return x; }
interface I {
(): string;
}
var i: I;
class C {
foo: string;
}
var a: { (): string };
var b: { new (): string };
var c: { (): string; (x): string };
var r1 = foo((x) => x);
var r2 = foo((x: string) => x);
var r3 = foo(function (x) { return x });
var r4 = foo(function (x: string) { return x });
var r5 = foo(i);
var r8 = foo(c);
interface I2<T> {
(x: T): T;
}
var i2: I2<string>;
class C2<T> {
foo: T;
}
var a2: { <T>(x: T): T };
var b2: { new <T>(x: T): T };
var c2: { <T>(x: T): T; <T>(x: T, y: T): T };
var r9 = foo(function <U>(x: U) { return x; });
var r10 = foo(<U extends string>(x: U) => x);
var r12 = foo(i2);
var r15 = foo(c2); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionExpressionContextualTyping1.ts | TypeScript | // When a function expression with no type parameters and no parameter type annotations
// is contextually typed (section 4.19) by a type T and a contextual signature S can be extracted from T
enum E { red, blue }
// A contextual signature S is extracted from a function type T as follows:
// If T is a function type with exactly one call signature, and if that call signature is non- generic, S is that signature.
var a0: (n: number, s: string) => number = (num, str) => {
num.toExponential();
return 0;
}
class Class<T> {
foo() { }
}
var a1: (c: Class<Number>) => number = (a1) => {
a1.foo();
return 1;
}
// A contextual signature S is extracted from a function type T as follows:
// If T is a union type, let U be the set of element types in T that have call signatures.
// If each type in U has exactly one call signature and that call signature is non- generic,
// and if all of the signatures are identical ignoring return types,
// then S is a signature with the same parameters and a union of the return types.
var b1: ((s: string, w: boolean) => void) | ((s: string, w: boolean) => string);
b1 = (k, h) => { };
var b2: typeof a0 | ((n: number, s: string) => string);
b2 = (foo, bar) => { return foo + 1; }
b2 = (foo, bar) => { return "hello"; }
var b3: (name: string, num: number, boo: boolean) => void;
b3 = (name, number) => { };
var b4: (n: E) => string = (number = 1) => { return "hello"; };
var b5: (n: {}) => string = (number = "string") => { return "hello"; };
// A contextual signature S is extracted from a function type T as follows:
// Otherwise, no contextual signature can be extracted from T and S is undefined.
var b6: ((s: string, w: boolean) => void) | ((n: number) => number);
var b7: ((s: string, w: boolean) => void) | ((s: string, w: number) => string);
b6 = (k) => { k.toLowerCase() };
b6 = (i) => {
i.toExponential();
return i;
}; // Per spec, no contextual signature can be extracted in this case. (Otherwise clause)
b7 = (j, m) => { }; // Per spec, no contextual signature can be extracted in this case. (Otherwise clause)
class C<T, U> {
constructor() {
var k: ((j: T, k: U) => (T|U)[]) | ((j: number,k :U) => number[]) = (j, k) => {
return [j, k];
} // Per spec, no contextual signature can be extracted in this case.
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionExpressionContextualTyping2.ts | TypeScript | // A contextual signature S is extracted from a function type T as follows:
// If T is a function type with exactly one call signature, and if that call signature is non- generic, S is that signature.
// If T is a union type, let U be the set of element types in T that have call signatures.
// If each type in U has exactly one call signature and that call signature is non- generic,
// and if all of the signatures are identical ignoring return types, then S is a signature
// with the same parameters and a union of the return types.
// Otherwise, no contextual signature can be extracted from T and S is undefined.
var a0: (n: number, s: string) => number
var a1: typeof a0 | ((n: number, s: string) => string);
a1 = (foo, bar) => { return true; } // Error | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionExpressionContextualTyping3.ts | TypeScript | // @noImplicitAny: true
// #31114
declare function f<T>(value: T | number): void;
f((a: any) => "")
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionImplementationErrors.ts | TypeScript | // @allowUnreachableCode: true
// FunctionExpression with no return type annotation with multiple return statements with unrelated types
var f1 = function () {
return '';
return 3;
};
var f2 = function x() {
return '';
return 3;
};
var f3 = () => {
return '';
return 3;
};
// FunctionExpression with no return type annotation with return branch of number[] and other of string[]
var f4 = function () {
if (true) {
return [''];
} else {
return [1];
}
}
// Function implemetnation with non -void return type annotation with no return
function f5(): number {
}
var m;
// Function signature with parameter initializer referencing in scope local variable
function f6(n = m) {
var m = 4;
}
// Function signature with initializer referencing other parameter to the right
function f7(n = m, m?) {
}
// FunctionExpression with non -void return type annotation with a throw, no return, and other code
// Should be error but isn't
undefined === function (): number {
throw undefined;
var x = 4;
};
class Base { private x; }
class AnotherClass { private y; }
class Derived1 extends Base { private m; }
class Derived2 extends Base { private n; }
function f8() {
return new Derived1();
return new Derived2();
}
var f9 = function () {
return new Derived1();
return new Derived2();
};
var f10 = () => {
return new Derived1();
return new Derived2();
};
function f11() {
return new Base();
return new AnotherClass();
}
var f12 = function () {
return new Base();
return new AnotherClass();
};
var f13 = () => {
return new Base();
return new AnotherClass();
};
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionImplementations.ts | TypeScript | // @allowUnreachableCode: true
// FunctionExpression with no return type annotation and no return statement returns void
var v: void = function () { } ();
// FunctionExpression f with no return type annotation and directly references f in its body returns any
var a: any = function f() {
return f;
};
var a: any = function f() {
return f();
};
// FunctionExpression f with no return type annotation and indirectly references f in its body returns any
var a: any = function f() {
var x = f;
return x;
};
// Two mutually recursive function implementations with no return type annotations
function rec1() {
return rec2();
}
function rec2() {
return rec1();
}
var a = rec1();
var a = rec2();
// Two mutually recursive function implementations with return type annotation in one
function rec3(): number {
return rec4();
}
function rec4() {
return rec3();
}
var n: number;
var n = rec3();
var n = rec4();
// FunctionExpression with no return type annotation and returns a number
var n = function () {
return 3;
} ();
// FunctionExpression with no return type annotation and returns null
var nu = null;
var nu = function () {
return null;
} ();
// FunctionExpression with no return type annotation and returns undefined
var un = undefined;
var un = function () {
return undefined;
} ();
// FunctionExpression with no return type annotation and returns a type parameter type
var n = function <T>(x: T) {
return x;
} (4);
// FunctionExpression with no return type annotation and returns a constrained type parameter type
var n = function <T extends {}>(x: T) {
return x;
} (4);
// FunctionExpression with no return type annotation with multiple return statements with identical types
var n = function () {
return 3;
return 5;
}();
// Otherwise, the inferred return type is the first of the types of the return statement expressions
// in the function body that is a supertype of each of the others,
// ignoring return statements with no expressions.
// A compile - time error occurs if no return statement expression has a type that is a supertype of each of the others.
// FunctionExpression with no return type annotation with multiple return statements with subtype relation between returns
class Base { private m; }
class Derived extends Base { private q; }
var b: Base;
var b = function () {
return new Base(); return new Derived();
} ();
// FunctionExpression with no return type annotation with multiple return statements with one a recursive call
var a = function f() {
return new Base(); return new Derived(); return f(); // ?
} ();
// FunctionExpression with non -void return type annotation with a single throw statement
undefined === function (): number {
throw undefined;
};
// Type of 'this' in function implementation is 'any'
function thisFunc() {
var x = this;
var x: any;
}
// Function signature with optional parameter, no type annotation and initializer has initializer's type
function opt1(n = 4) {
var m = n;
var m: number;
}
// Function signature with optional parameter, no type annotation and initializer has initializer's widened type
function opt2(n = { x: null, y: undefined }) {
var m = n;
var m: { x: any; y: any };
}
// Function signature with initializer referencing other parameter to the left
function opt3(n: number, m = n) {
var y = m;
var y: number;
}
// Function signature with optional parameter has correct codegen
// (tested above)
// FunctionExpression with non -void return type annotation return with no expression
function f6(): number {
return;
}
class Derived2 extends Base { private r: string; }
class AnotherClass { private x }
// if f is a contextually typed function expression, the inferred return type is the union type
// of the types of the return statement expressions in the function body,
// ignoring return statements with no expressions.
var f7: (x: number) => string | number = x => { // should be (x: number) => number | string
if (x < 0) { return x; }
return x.toString();
}
var f8: (x: number) => any = x => { // should be (x: number) => Base
return new Base();
return new Derived2();
}
var f9: (x: number) => any = x => { // should be (x: number) => Base
return new Base();
return new Derived();
return new Derived2();
}
var f10: (x: number) => any = x => { // should be (x: number) => Derived | Derived1
return new Derived();
return new Derived2();
}
var f11: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass
return new Base();
return new AnotherClass();
}
var f12: (x: number) => any = x => { // should be (x: number) => Base | AnotherClass
return new Base();
return; // should be ignored
return new AnotherClass();
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionLiteral.ts | TypeScript | // basic valid forms of function literals
var x = () => 1;
var x: {
(): number;
}
var y: { (x: string): string; };
var y: (x: string) => string;
var y2: { <T>(x: T): T; } = <T>(x: T) => x
var z: { new (x: number): number; };
var z: new (x: number) => number; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionLiteralForOverloads.ts | TypeScript | // basic uses of function literals with overloads
var f: {
(x: string): string;
(x: number): number;
} = (x) => x;
var f2: {
<T>(x: string): string;
<T>(x: number): number;
} = (x) => x;
var f3: {
<T>(x: T): string;
<T>(x: T): number;
} = (x) => x;
var f4: {
<T>(x: string): T;
<T>(x: number): T;
} = (x) => x; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionLiteralForOverloads2.ts | TypeScript | // basic uses of function literals with constructor overloads
class C {
constructor(x: string);
constructor(x: number);
constructor(x) { }
}
class D<T> {
constructor(x: string);
constructor(x: number);
constructor(x) { }
}
var f: {
new(x: string): C;
new(x: number): C;
} = C;
var f2: {
new<T>(x: string): C;
new<T>(x: number): C;
} = C;
var f3: {
new<T>(x: string): D<T>;
new<T>(x: number): D<T>;
} = D; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionLiterals.ts | TypeScript | // PropName<TypeParamList>(ParamList):ReturnType is equivalent to PropName: { <TypeParamList>(ParamList): ReturnType }
var b: {
func1(x: number): number; // Method signature
func2: (x: number) => number; // Function type literal
func3: { (x: number): number }; // Object type literal
}
// no errors
b.func1 = b.func2;
b.func1 = b.func3;
b.func2 = b.func1;
b.func2 = b.func3;
b.func3 = b.func1;
b.func3 = b.func2;
var c: {
func4(x: number): number;
func4(s: string): string;
func5: {
(x: number): number;
(s: string): string;
};
};
// no errors
c.func4 = c.func5;
c.func5 = c.func4;
// generic versions
var b2: {
func1<T>(x: T): number; // Method signature
func2: <T>(x: T) => number; // Function type literal
func3: { <T>(x: T): number }; // Object type literal
}
// no errors
b2.func1 = b2.func2;
b2.func1 = b2.func3;
b2.func2 = b2.func1;
b2.func2 = b2.func3;
b2.func3 = b2.func1;
b2.func3 = b2.func2;
var c2: {
func4<T>(x: T): number;
func4<T>(s: T): string;
func5: {
<T>(x: T): number;
<T>(s: T): string;
};
};
// no errors
c2.func4 = c2.func5;
c2.func5 = c2.func4;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionNameConflicts.ts | TypeScript | //Function and variable of the same name in same declaration space
//Function overload with different name from implementation signature
module M {
function fn1() { }
var fn1;
var fn2;
function fn2() { }
}
function fn3() { }
var fn3;
function func() {
var fn4;
function fn4() { }
function fn5() { }
var fn5;
}
function over();
function overrr() {
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionOverloadCompatibilityWithVoid01.ts | TypeScript | function f(x: string): number;
function f(x: string): void {
return;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionOverloadCompatibilityWithVoid02.ts | TypeScript | function f(x: string): void;
function f(x: string): number {
return 0;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionOverloadCompatibilityWithVoid03.ts | TypeScript | function f(x: string): void;
function f(x: string): void {
return;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionOverloadErrors.ts | TypeScript | //Function overload signature with initializer
function fn1(x = 3);
function fn1() { }
//Multiple function overload signatures that are identical
function fn2a();
function fn2a();
function fn2a() {
}
function fn2b(n: number[]);
function fn2b(n: Array<number>);
function fn2b() {
}
//Multiple function overload signatures that differ only by return type
function fn3(x: string): string;
function fn3(y: string): number;
function fn3(): any {
return null;
}
//Function overload with rest param and another with only an optional parameter
function fn6(...t: any[]);
function fn6(x?: any);
function fn6() { }
//Function overload with rest param and another with only optional parameters
function fn7(...t: any[]);
function fn7(x?: any, y?: any, z?: any);
function fn7() { }
//Function overloads that differ only by type parameter name
function fn8<T>(n: string);
function fn8<S>(n: string);
function fn8() { }
//Function overloads that differ only by type parameter name when used in parameter type annotations
function fn9<T>(n: T);
function fn9<S>(n: S);
function fn9() { }
//Function overloads that differ only by type parameter constraints
function fn10<T extends Window>();
function fn10<S extends Date>();
function fn10() { }
// (actually OK)
//Function overloads that differ only by type parameter constraints where constraints are structually identical
function fn11<T extends Window>();
function fn11<S extends typeof window>();
function fn11() { }
//Function overloads that differ only by type parameter constraints where constraints include infinitely recursive type reference
interface List<T> {
parents: List<List<T>>;
}
function fn12<T extends List<List<any>>>();
function fn12<T extends List<any>>();
function fn12() { }
//Function overloads that differ by accessibility
class cls {
public f();
private f(s: string);
f() { }
private g(s: string);
public g();
g() { }
}
//Function overloads with differing export
module M {
export function fn1();
function fn1(n: string);
function fn1() { }
function fn2(n: string);
export function fn2();
export function fn2() { }
}
//Function overloads with differing ambience
declare function dfn1();
function dfn1(s: string);
function dfn1() { }
function dfn2();
declare function dfn2(s: string);
function dfn2() { }
//Function overloads with fewer params than implementation signature
function fewerParams();
function fewerParams(n: string) {
}
//Function implementation whose parameter types are not assignable to all corresponding overload signature parameters
function fn13(n: string);
function fn13(n: number) { }
//Function overloads where return types are not all subtype of implementation return type
function fn14(n: string): string;
function fn14() {
return 3;
}
//Function overloads where return types are different infinitely recursive type reference
function fn15<T extends List<List<any>>>(): T;
function fn15<T extends List<any>>(): T;
function fn15() {
return undefined;
}
//Function overloads which use initializer expressions
function initExpr(n = 13);
function initExpr() { }
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionParameterObjectRestAndInitializers.ts | TypeScript | // @target: es2015
// @noTypesAndSymbols: true
// https://github.com/microsoft/TypeScript/issues/47079
function f({a, ...x}, b = a) {
return b;
}
function g({a, ...x}, b = ({a}, b = a) => {}) {
return b;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionWithMultipleReturnStatements.ts | TypeScript | // @allowUnreachableCode: true
// return type of a function with multiple returns is the BCT of each return statement
// it is an error if there is no single BCT, these are error cases
function f1() {
if (true) {
return 1;
} else {
return '';
}
}
function f2() {
if (true) {
return 1;
} else if (false) {
return 2;
} else {
return '';
}
}
function f3() {
try {
return 1;
}
catch (e) {
return '';
}
}
function f4() {
try {
return 1;
}
catch (e) {
}
finally {
return '';
}
}
function f5() {
return 1;
return '';
}
function f6<T, U>(x: T, y:U) {
if (true) {
return x;
} else {
return y;
}
}
function f8<T extends U, U extends V, V>(x: T, y: U) {
if (true) {
return x;
} else {
return y;
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/functionWithMultipleReturnStatements2.ts | TypeScript | // @allowUnreachableCode: true
// return type of a function with multiple returns is the BCT of each return statement
// no errors expected here
function f1() {
if (true) {
return 1;
} else {
return null;
}
}
function f2() {
if (true) {
return 1;
} else if (false) {
return null;
} else {
return 2;
}
}
function f4() {
try {
return 1;
}
catch (e) {
return undefined;
}
finally {
return 1;
}
}
function f5() {
return 1;
return new Object();
}
function f6<T>(x: T) {
if (true) {
return x;
} else {
return null;
}
}
//function f7<T extends U, U>(x: T, y: U) {
// if (true) {
// return x;
// } else {
// return y;
// }
//}
var a: { x: number; y?: number };
var b: { x: number; z?: number };
// returns typeof a
function f9() {
if (true) {
return a;
} else {
return b;
}
}
// returns typeof b
function f10() {
if (true) {
return b;
} else {
return a;
}
}
// returns number => void
function f11() {
if (true) {
return (x: number) => { }
} else {
return (x: Object) => { }
}
}
// returns Object => void
function f12() {
if (true) {
return (x: Object) => { }
} else {
return (x: number) => { }
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatedContextualTyping.ts | TypeScript | // @allowUnreachableCode: true
class Base { private p; }
class Derived1 extends Base { private m; }
class Derived2 extends Base { private n; }
interface Genric<T> { func(n: T[]); }
var b = new Base(), d1 = new Derived1(), d2 = new Derived2();
var x1: () => Base[] = () => [d1, d2];
var x2: () => Base[] = function() { return [d1, d2] };
var x3: () => Base[] = function named() { return [d1, d2] };
var x4: { (): Base[]; } = () => [d1, d2];
var x5: { (): Base[]; } = function() { return [d1, d2] };
var x6: { (): Base[]; } = function named() { return [d1, d2] };
var x7: Base[] = [d1, d2];
var x8: Array<Base> = [d1, d2];
var x9: { [n: number]: Base; } = [d1, d2];
var x10: {n: Base[]; } = { n: [d1, d2] };
var x11: (s: Base[]) => any = n => { var n: Base[]; return null; };
var x12: Genric<Base> = { func: n => { return [d1, d2]; } };
class x13 { member: () => Base[] = () => [d1, d2] }
class x14 { member: () => Base[] = function() { return [d1, d2] } }
class x15 { member: () => Base[] = function named() { return [d1, d2] } }
class x16 { member: { (): Base[]; } = () => [d1, d2] }
class x17 { member: { (): Base[]; } = function() { return [d1, d2] } }
class x18 { member: { (): Base[]; } = function named() { return [d1, d2] } }
class x19 { member: Base[] = [d1, d2] }
class x20 { member: Array<Base> = [d1, d2] }
class x21 { member: { [n: number]: Base; } = [d1, d2] }
class x22 { member: {n: Base[]; } = { n: [d1, d2] } }
class x23 { member: (s: Base[]) => any = n => { var n: Base[]; return null; } }
class x24 { member: Genric<Base> = { func: n => { return [d1, d2]; } } }
class x25 { private member: () => Base[] = () => [d1, d2] }
class x26 { private member: () => Base[] = function() { return [d1, d2] } }
class x27 { private member: () => Base[] = function named() { return [d1, d2] } }
class x28 { private member: { (): Base[]; } = () => [d1, d2] }
class x29 { private member: { (): Base[]; } = function() { return [d1, d2] } }
class x30 { private member: { (): Base[]; } = function named() { return [d1, d2] } }
class x31 { private member: Base[] = [d1, d2] }
class x32 { private member: Array<Base> = [d1, d2] }
class x33 { private member: { [n: number]: Base; } = [d1, d2] }
class x34 { private member: {n: Base[]; } = { n: [d1, d2] } }
class x35 { private member: (s: Base[]) => any = n => { var n: Base[]; return null; } }
class x36 { private member: Genric<Base> = { func: n => { return [d1, d2]; } } }
class x37 { public member: () => Base[] = () => [d1, d2] }
class x38 { public member: () => Base[] = function() { return [d1, d2] } }
class x39 { public member: () => Base[] = function named() { return [d1, d2] } }
class x40 { public member: { (): Base[]; } = () => [d1, d2] }
class x41 { public member: { (): Base[]; } = function() { return [d1, d2] } }
class x42 { public member: { (): Base[]; } = function named() { return [d1, d2] } }
class x43 { public member: Base[] = [d1, d2] }
class x44 { public member: Array<Base> = [d1, d2] }
class x45 { public member: { [n: number]: Base; } = [d1, d2] }
class x46 { public member: {n: Base[]; } = { n: [d1, d2] } }
class x47 { public member: (s: Base[]) => any = n => { var n: Base[]; return null; } }
class x48 { public member: Genric<Base> = { func: n => { return [d1, d2]; } } }
class x49 { static member: () => Base[] = () => [d1, d2] }
class x50 { static member: () => Base[] = function() { return [d1, d2] } }
class x51 { static member: () => Base[] = function named() { return [d1, d2] } }
class x52 { static member: { (): Base[]; } = () => [d1, d2] }
class x53 { static member: { (): Base[]; } = function() { return [d1, d2] } }
class x54 { static member: { (): Base[]; } = function named() { return [d1, d2] } }
class x55 { static member: Base[] = [d1, d2] }
class x56 { static member: Array<Base> = [d1, d2] }
class x57 { static member: { [n: number]: Base; } = [d1, d2] }
class x58 { static member: {n: Base[]; } = { n: [d1, d2] } }
class x59 { static member: (s: Base[]) => any = n => { var n: Base[]; return null; } }
class x60 { static member: Genric<Base> = { func: n => { return [d1, d2]; } } }
class x61 { private static member: () => Base[] = () => [d1, d2] }
class x62 { private static member: () => Base[] = function() { return [d1, d2] } }
class x63 { private static member: () => Base[] = function named() { return [d1, d2] } }
class x64 { private static member: { (): Base[]; } = () => [d1, d2] }
class x65 { private static member: { (): Base[]; } = function() { return [d1, d2] } }
class x66 { private static member: { (): Base[]; } = function named() { return [d1, d2] } }
class x67 { private static member: Base[] = [d1, d2] }
class x68 { private static member: Array<Base> = [d1, d2] }
class x69 { private static member: { [n: number]: Base; } = [d1, d2] }
class x70 { private static member: {n: Base[]; } = { n: [d1, d2] } }
class x71 { private static member: (s: Base[]) => any = n => { var n: Base[]; return null; } }
class x72 { private static member: Genric<Base> = { func: n => { return [d1, d2]; } } }
class x73 { public static member: () => Base[] = () => [d1, d2] }
class x74 { public static member: () => Base[] = function() { return [d1, d2] } }
class x75 { public static member: () => Base[] = function named() { return [d1, d2] } }
class x76 { public static member: { (): Base[]; } = () => [d1, d2] }
class x77 { public static member: { (): Base[]; } = function() { return [d1, d2] } }
class x78 { public static member: { (): Base[]; } = function named() { return [d1, d2] } }
class x79 { public static member: Base[] = [d1, d2] }
class x80 { public static member: Array<Base> = [d1, d2] }
class x81 { public static member: { [n: number]: Base; } = [d1, d2] }
class x82 { public static member: {n: Base[]; } = { n: [d1, d2] } }
class x83 { public static member: (s: Base[]) => any = n => { var n: Base[]; return null; } }
class x84 { public static member: Genric<Base> = { func: n => { return [d1, d2]; } } }
class x85 { constructor(parm: () => Base[] = () => [d1, d2]) { } }
class x86 { constructor(parm: () => Base[] = function() { return [d1, d2] }) { } }
class x87 { constructor(parm: () => Base[] = function named() { return [d1, d2] }) { } }
class x88 { constructor(parm: { (): Base[]; } = () => [d1, d2]) { } }
class x89 { constructor(parm: { (): Base[]; } = function() { return [d1, d2] }) { } }
class x90 { constructor(parm: { (): Base[]; } = function named() { return [d1, d2] }) { } }
class x91 { constructor(parm: Base[] = [d1, d2]) { } }
class x92 { constructor(parm: Array<Base> = [d1, d2]) { } }
class x93 { constructor(parm: { [n: number]: Base; } = [d1, d2]) { } }
class x94 { constructor(parm: {n: Base[]; } = { n: [d1, d2] }) { } }
class x95 { constructor(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } }
class x96 { constructor(parm: Genric<Base> = { func: n => { return [d1, d2]; } }) { } }
class x97 { constructor(public parm: () => Base[] = () => [d1, d2]) { } }
class x98 { constructor(public parm: () => Base[] = function() { return [d1, d2] }) { } }
class x99 { constructor(public parm: () => Base[] = function named() { return [d1, d2] }) { } }
class x100 { constructor(public parm: { (): Base[]; } = () => [d1, d2]) { } }
class x101 { constructor(public parm: { (): Base[]; } = function() { return [d1, d2] }) { } }
class x102 { constructor(public parm: { (): Base[]; } = function named() { return [d1, d2] }) { } }
class x103 { constructor(public parm: Base[] = [d1, d2]) { } }
class x104 { constructor(public parm: Array<Base> = [d1, d2]) { } }
class x105 { constructor(public parm: { [n: number]: Base; } = [d1, d2]) { } }
class x106 { constructor(public parm: {n: Base[]; } = { n: [d1, d2] }) { } }
class x107 { constructor(public parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } }
class x108 { constructor(public parm: Genric<Base> = { func: n => { return [d1, d2]; } }) { } }
class x109 { constructor(private parm: () => Base[] = () => [d1, d2]) { } }
class x110 { constructor(private parm: () => Base[] = function() { return [d1, d2] }) { } }
class x111 { constructor(private parm: () => Base[] = function named() { return [d1, d2] }) { } }
class x112 { constructor(private parm: { (): Base[]; } = () => [d1, d2]) { } }
class x113 { constructor(private parm: { (): Base[]; } = function() { return [d1, d2] }) { } }
class x114 { constructor(private parm: { (): Base[]; } = function named() { return [d1, d2] }) { } }
class x115 { constructor(private parm: Base[] = [d1, d2]) { } }
class x116 { constructor(private parm: Array<Base> = [d1, d2]) { } }
class x117 { constructor(private parm: { [n: number]: Base; } = [d1, d2]) { } }
class x118 { constructor(private parm: {n: Base[]; } = { n: [d1, d2] }) { } }
class x119 { constructor(private parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { } }
class x120 { constructor(private parm: Genric<Base> = { func: n => { return [d1, d2]; } }) { } }
function x121(parm: () => Base[] = () => [d1, d2]) { }
function x122(parm: () => Base[] = function() { return [d1, d2] }) { }
function x123(parm: () => Base[] = function named() { return [d1, d2] }) { }
function x124(parm: { (): Base[]; } = () => [d1, d2]) { }
function x125(parm: { (): Base[]; } = function() { return [d1, d2] }) { }
function x126(parm: { (): Base[]; } = function named() { return [d1, d2] }) { }
function x127(parm: Base[] = [d1, d2]) { }
function x128(parm: Array<Base> = [d1, d2]) { }
function x129(parm: { [n: number]: Base; } = [d1, d2]) { }
function x130(parm: {n: Base[]; } = { n: [d1, d2] }) { }
function x131(parm: (s: Base[]) => any = n => { var n: Base[]; return null; }) { }
function x132(parm: Genric<Base> = { func: n => { return [d1, d2]; } }) { }
function x133(): () => Base[] { return () => [d1, d2]; }
function x134(): () => Base[] { return function() { return [d1, d2] }; }
function x135(): () => Base[] { return function named() { return [d1, d2] }; }
function x136(): { (): Base[]; } { return () => [d1, d2]; }
function x137(): { (): Base[]; } { return function() { return [d1, d2] }; }
function x138(): { (): Base[]; } { return function named() { return [d1, d2] }; }
function x139(): Base[] { return [d1, d2]; }
function x140(): Array<Base> { return [d1, d2]; }
function x141(): { [n: number]: Base; } { return [d1, d2]; }
function x142(): {n: Base[]; } { return { n: [d1, d2] }; }
function x143(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; }
function x144(): Genric<Base> { return { func: n => { return [d1, d2]; } }; }
function x145(): () => Base[] { return () => [d1, d2]; return () => [d1, d2]; }
function x146(): () => Base[] { return function() { return [d1, d2] }; return function() { return [d1, d2] }; }
function x147(): () => Base[] { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; }
function x148(): { (): Base[]; } { return () => [d1, d2]; return () => [d1, d2]; }
function x149(): { (): Base[]; } { return function() { return [d1, d2] }; return function() { return [d1, d2] }; }
function x150(): { (): Base[]; } { return function named() { return [d1, d2] }; return function named() { return [d1, d2] }; }
function x151(): Base[] { return [d1, d2]; return [d1, d2]; }
function x152(): Array<Base> { return [d1, d2]; return [d1, d2]; }
function x153(): { [n: number]: Base; } { return [d1, d2]; return [d1, d2]; }
function x154(): {n: Base[]; } { return { n: [d1, d2] }; return { n: [d1, d2] }; }
function x155(): (s: Base[]) => any { return n => { var n: Base[]; return null; }; return n => { var n: Base[]; return null; }; }
function x156(): Genric<Base> { return { func: n => { return [d1, d2]; } }; return { func: n => { return [d1, d2]; } }; }
var x157: () => () => Base[] = () => { return () => [d1, d2]; };
var x158: () => () => Base[] = () => { return function() { return [d1, d2] }; };
var x159: () => () => Base[] = () => { return function named() { return [d1, d2] }; };
var x160: () => { (): Base[]; } = () => { return () => [d1, d2]; };
var x161: () => { (): Base[]; } = () => { return function() { return [d1, d2] }; };
var x162: () => { (): Base[]; } = () => { return function named() { return [d1, d2] }; };
var x163: () => Base[] = () => { return [d1, d2]; };
var x164: () => Array<Base> = () => { return [d1, d2]; };
var x165: () => { [n: number]: Base; } = () => { return [d1, d2]; };
var x166: () => {n: Base[]; } = () => { return { n: [d1, d2] }; };
var x167: () => (s: Base[]) => any = () => { return n => { var n: Base[]; return null; }; };
var x168: () => Genric<Base> = () => { return { func: n => { return [d1, d2]; } }; };
var x169: () => () => Base[] = function() { return () => [d1, d2]; };
var x170: () => () => Base[] = function() { return function() { return [d1, d2] }; };
var x171: () => () => Base[] = function() { return function named() { return [d1, d2] }; };
var x172: () => { (): Base[]; } = function() { return () => [d1, d2]; };
var x173: () => { (): Base[]; } = function() { return function() { return [d1, d2] }; };
var x174: () => { (): Base[]; } = function() { return function named() { return [d1, d2] }; };
var x175: () => Base[] = function() { return [d1, d2]; };
var x176: () => Array<Base> = function() { return [d1, d2]; };
var x177: () => { [n: number]: Base; } = function() { return [d1, d2]; };
var x178: () => {n: Base[]; } = function() { return { n: [d1, d2] }; };
var x179: () => (s: Base[]) => any = function() { return n => { var n: Base[]; return null; }; };
var x180: () => Genric<Base> = function() { return { func: n => { return [d1, d2]; } }; };
module x181 { var t: () => Base[] = () => [d1, d2]; }
module x182 { var t: () => Base[] = function() { return [d1, d2] }; }
module x183 { var t: () => Base[] = function named() { return [d1, d2] }; }
module x184 { var t: { (): Base[]; } = () => [d1, d2]; }
module x185 { var t: { (): Base[]; } = function() { return [d1, d2] }; }
module x186 { var t: { (): Base[]; } = function named() { return [d1, d2] }; }
module x187 { var t: Base[] = [d1, d2]; }
module x188 { var t: Array<Base> = [d1, d2]; }
module x189 { var t: { [n: number]: Base; } = [d1, d2]; }
module x190 { var t: {n: Base[]; } = { n: [d1, d2] }; }
module x191 { var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; }
module x192 { var t: Genric<Base> = { func: n => { return [d1, d2]; } }; }
module x193 { export var t: () => Base[] = () => [d1, d2]; }
module x194 { export var t: () => Base[] = function() { return [d1, d2] }; }
module x195 { export var t: () => Base[] = function named() { return [d1, d2] }; }
module x196 { export var t: { (): Base[]; } = () => [d1, d2]; }
module x197 { export var t: { (): Base[]; } = function() { return [d1, d2] }; }
module x198 { export var t: { (): Base[]; } = function named() { return [d1, d2] }; }
module x199 { export var t: Base[] = [d1, d2]; }
module x200 { export var t: Array<Base> = [d1, d2]; }
module x201 { export var t: { [n: number]: Base; } = [d1, d2]; }
module x202 { export var t: {n: Base[]; } = { n: [d1, d2] }; }
module x203 { export var t: (s: Base[]) => any = n => { var n: Base[]; return null; }; }
module x204 { export var t: Genric<Base> = { func: n => { return [d1, d2]; } }; }
var x206 = <() => Base[]>function() { return [d1, d2] };
var x207 = <() => Base[]>function named() { return [d1, d2] };
var x209 = <{ (): Base[]; }>function() { return [d1, d2] };
var x210 = <{ (): Base[]; }>function named() { return [d1, d2] };
var x211 = <Base[]>[d1, d2];
var x212 = <Array<Base>>[d1, d2];
var x213 = <{ [n: number]: Base; }>[d1, d2];
var x214 = <{n: Base[]; } >{ n: [d1, d2] };
var x216 = <Genric<Base>>{ func: n => { return [d1, d2]; } };
var x217 = (<() => Base[]>undefined) || function() { return [d1, d2] };
var x218 = (<() => Base[]>undefined) || function named() { return [d1, d2] };
var x219 = (<{ (): Base[]; }>undefined) || function() { return [d1, d2] };
var x220 = (<{ (): Base[]; }>undefined) || function named() { return [d1, d2] };
var x221 = (<Base[]>undefined) || [d1, d2];
var x222 = (<Array<Base>>undefined) || [d1, d2];
var x223 = (<{ [n: number]: Base; }>undefined) || [d1, d2];
var x224 = (<{n: Base[]; } >undefined) || { n: [d1, d2] };
var x225: () => Base[]; x225 = () => [d1, d2];
var x226: () => Base[]; x226 = function() { return [d1, d2] };
var x227: () => Base[]; x227 = function named() { return [d1, d2] };
var x228: { (): Base[]; }; x228 = () => [d1, d2];
var x229: { (): Base[]; }; x229 = function() { return [d1, d2] };
var x230: { (): Base[]; }; x230 = function named() { return [d1, d2] };
var x231: Base[]; x231 = [d1, d2];
var x232: Array<Base>; x232 = [d1, d2];
var x233: { [n: number]: Base; }; x233 = [d1, d2];
var x234: {n: Base[]; } ; x234 = { n: [d1, d2] };
var x235: (s: Base[]) => any; x235 = n => { var n: Base[]; return null; };
var x236: Genric<Base>; x236 = { func: n => { return [d1, d2]; } };
var x237: { n: () => Base[]; } = { n: () => [d1, d2] };
var x238: { n: () => Base[]; } = { n: function() { return [d1, d2] } };
var x239: { n: () => Base[]; } = { n: function named() { return [d1, d2] } };
var x240: { n: { (): Base[]; }; } = { n: () => [d1, d2] };
var x241: { n: { (): Base[]; }; } = { n: function() { return [d1, d2] } };
var x242: { n: { (): Base[]; }; } = { n: function named() { return [d1, d2] } };
var x243: { n: Base[]; } = { n: [d1, d2] };
var x244: { n: Array<Base>; } = { n: [d1, d2] };
var x245: { n: { [n: number]: Base; }; } = { n: [d1, d2] };
var x246: { n: {n: Base[]; } ; } = { n: { n: [d1, d2] } };
var x247: { n: (s: Base[]) => any; } = { n: n => { var n: Base[]; return null; } };
var x248: { n: Genric<Base>; } = { n: { func: n => { return [d1, d2]; } } };
var x252: { (): Base[]; }[] = [() => [d1, d2]];
var x253: { (): Base[]; }[] = [function() { return [d1, d2] }];
var x254: { (): Base[]; }[] = [function named() { return [d1, d2] }];
var x255: Base[][] = [[d1, d2]];
var x256: Array<Base>[] = [[d1, d2]];
var x257: { [n: number]: Base; }[] = [[d1, d2]];
var x258: {n: Base[]; } [] = [{ n: [d1, d2] }];
var x260: Genric<Base>[] = [{ func: n => { return [d1, d2]; } }];
var x261: () => Base[] = function() { return [d1, d2] } || undefined;
var x262: () => Base[] = function named() { return [d1, d2] } || undefined;
var x263: { (): Base[]; } = function() { return [d1, d2] } || undefined;
var x264: { (): Base[]; } = function named() { return [d1, d2] } || undefined;
var x265: Base[] = [d1, d2] || undefined;
var x266: Array<Base> = [d1, d2] || undefined;
var x267: { [n: number]: Base; } = [d1, d2] || undefined;
var x268: {n: Base[]; } = { n: [d1, d2] } || undefined;
var x269: () => Base[] = undefined || function() { return [d1, d2] };
var x270: () => Base[] = undefined || function named() { return [d1, d2] };
var x271: { (): Base[]; } = undefined || function() { return [d1, d2] };
var x272: { (): Base[]; } = undefined || function named() { return [d1, d2] };
var x273: Base[] = undefined || [d1, d2];
var x274: Array<Base> = undefined || [d1, d2];
var x275: { [n: number]: Base; } = undefined || [d1, d2];
var x276: {n: Base[]; } = undefined || { n: [d1, d2] };
var x277: () => Base[] = function() { return [d1, d2] } || function() { return [d1, d2] };
var x278: () => Base[] = function named() { return [d1, d2] } || function named() { return [d1, d2] };
var x279: { (): Base[]; } = function() { return [d1, d2] } || function() { return [d1, d2] };
var x280: { (): Base[]; } = function named() { return [d1, d2] } || function named() { return [d1, d2] };
var x281: Base[] = [d1, d2] || [d1, d2];
var x282: Array<Base> = [d1, d2] || [d1, d2];
var x283: { [n: number]: Base; } = [d1, d2] || [d1, d2];
var x284: {n: Base[]; } = { n: [d1, d2] } || { n: [d1, d2] };
var x285: () => Base[] = true ? () => [d1, d2] : () => [d1, d2];
var x286: () => Base[] = true ? function() { return [d1, d2] } : function() { return [d1, d2] };
var x287: () => Base[] = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] };
var x288: { (): Base[]; } = true ? () => [d1, d2] : () => [d1, d2];
var x289: { (): Base[]; } = true ? function() { return [d1, d2] } : function() { return [d1, d2] };
var x290: { (): Base[]; } = true ? function named() { return [d1, d2] } : function named() { return [d1, d2] };
var x291: Base[] = true ? [d1, d2] : [d1, d2];
var x292: Array<Base> = true ? [d1, d2] : [d1, d2];
var x293: { [n: number]: Base; } = true ? [d1, d2] : [d1, d2];
var x294: {n: Base[]; } = true ? { n: [d1, d2] } : { n: [d1, d2] };
var x295: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; };
var x296: Genric<Base> = true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } };
var x297: () => Base[] = true ? undefined : () => [d1, d2];
var x298: () => Base[] = true ? undefined : function() { return [d1, d2] };
var x299: () => Base[] = true ? undefined : function named() { return [d1, d2] };
var x300: { (): Base[]; } = true ? undefined : () => [d1, d2];
var x301: { (): Base[]; } = true ? undefined : function() { return [d1, d2] };
var x302: { (): Base[]; } = true ? undefined : function named() { return [d1, d2] };
var x303: Base[] = true ? undefined : [d1, d2];
var x304: Array<Base> = true ? undefined : [d1, d2];
var x305: { [n: number]: Base; } = true ? undefined : [d1, d2];
var x306: {n: Base[]; } = true ? undefined : { n: [d1, d2] };
var x307: (s: Base[]) => any = true ? undefined : n => { var n: Base[]; return null; };
var x308: Genric<Base> = true ? undefined : { func: n => { return [d1, d2]; } };
var x309: () => Base[] = true ? () => [d1, d2] : undefined;
var x310: () => Base[] = true ? function() { return [d1, d2] } : undefined;
var x311: () => Base[] = true ? function named() { return [d1, d2] } : undefined;
var x312: { (): Base[]; } = true ? () => [d1, d2] : undefined;
var x313: { (): Base[]; } = true ? function() { return [d1, d2] } : undefined;
var x314: { (): Base[]; } = true ? function named() { return [d1, d2] } : undefined;
var x315: Base[] = true ? [d1, d2] : undefined;
var x316: Array<Base> = true ? [d1, d2] : undefined;
var x317: { [n: number]: Base; } = true ? [d1, d2] : undefined;
var x318: {n: Base[]; } = true ? { n: [d1, d2] } : undefined;
var x319: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : undefined;
var x320: Genric<Base> = true ? { func: n => { return [d1, d2]; } } : undefined;
function x321(n: () => Base[]) { }; x321(() => [d1, d2]);
function x322(n: () => Base[]) { }; x322(function() { return [d1, d2] });
function x323(n: () => Base[]) { }; x323(function named() { return [d1, d2] });
function x324(n: { (): Base[]; }) { }; x324(() => [d1, d2]);
function x325(n: { (): Base[]; }) { }; x325(function() { return [d1, d2] });
function x326(n: { (): Base[]; }) { }; x326(function named() { return [d1, d2] });
function x327(n: Base[]) { }; x327([d1, d2]);
function x328(n: Array<Base>) { }; x328([d1, d2]);
function x329(n: { [n: number]: Base; }) { }; x329([d1, d2]);
function x330(n: {n: Base[]; } ) { }; x330({ n: [d1, d2] });
function x331(n: (s: Base[]) => any) { }; x331(n => { var n: Base[]; return null; });
function x332(n: Genric<Base>) { }; x332({ func: n => { return [d1, d2]; } });
var x333 = (n: () => Base[]) => n; x333(() => [d1, d2]);
var x334 = (n: () => Base[]) => n; x334(function() { return [d1, d2] });
var x335 = (n: () => Base[]) => n; x335(function named() { return [d1, d2] });
var x336 = (n: { (): Base[]; }) => n; x336(() => [d1, d2]);
var x337 = (n: { (): Base[]; }) => n; x337(function() { return [d1, d2] });
var x338 = (n: { (): Base[]; }) => n; x338(function named() { return [d1, d2] });
var x339 = (n: Base[]) => n; x339([d1, d2]);
var x340 = (n: Array<Base>) => n; x340([d1, d2]);
var x341 = (n: { [n: number]: Base; }) => n; x341([d1, d2]);
var x342 = (n: {n: Base[]; } ) => n; x342({ n: [d1, d2] });
var x343 = (n: (s: Base[]) => any) => n; x343(n => { var n: Base[]; return null; });
var x344 = (n: Genric<Base>) => n; x344({ func: n => { return [d1, d2]; } });
var x345 = function(n: () => Base[]) { }; x345(() => [d1, d2]);
var x346 = function(n: () => Base[]) { }; x346(function() { return [d1, d2] });
var x347 = function(n: () => Base[]) { }; x347(function named() { return [d1, d2] });
var x348 = function(n: { (): Base[]; }) { }; x348(() => [d1, d2]);
var x349 = function(n: { (): Base[]; }) { }; x349(function() { return [d1, d2] });
var x350 = function(n: { (): Base[]; }) { }; x350(function named() { return [d1, d2] });
var x351 = function(n: Base[]) { }; x351([d1, d2]);
var x352 = function(n: Array<Base>) { }; x352([d1, d2]);
var x353 = function(n: { [n: number]: Base; }) { }; x353([d1, d2]);
var x354 = function(n: {n: Base[]; } ) { }; x354({ n: [d1, d2] });
var x355 = function(n: (s: Base[]) => any) { }; x355(n => { var n: Base[]; return null; });
var x356 = function(n: Genric<Base>) { }; x356({ func: n => { return [d1, d2]; } }); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorAssignability.ts | TypeScript | // @target: esnext
// @strict: true
// @noEmit: true
declare let _: any;
declare const g1: Generator<number, void, string>;
declare const g2: Generator<number, void, undefined>;
declare const g3: Generator<number, void, boolean>;
declare const g4: AsyncGenerator<number, void, string>;
declare const g5: AsyncGenerator<number, void, undefined>;
declare const g6: AsyncGenerator<number, void, boolean>;
// spread iterable
[...g1]; // error
[...g2]; // ok
// binding pattern over iterable
let [x1] = g1; // error
let [x2] = g2; // ok
// binding rest pattern over iterable
let [...y1] = g1; // error
let [...y2] = g2; // ok
// assignment pattern over iterable
[_] = g1; // error
[_] = g2; // ok
// assignment rest pattern over iterable
[..._] = g1; // error
[..._] = g2; // ok
// for-of over iterable
for (_ of g1); // error
for (_ of g2); // ok
async function asyncfn() {
// for-await-of over iterable
for await (_ of g1); // error
for await (_ of g2); // ok
// for-await-of over asynciterable
for await (_ of g4); // error
for await (_ of g5); // ok
}
function* f1(): Generator<number, void, boolean> {
// yield* over iterable
yield* g1; // error
yield* g3; // ok
}
async function* f2(): AsyncGenerator<number, void, boolean> {
// yield* over iterable
yield* g1; // error
yield* g3; // ok
// yield* over asynciterable
yield* g4; // error
yield* g6; // ok
}
async function f3() {
const syncGenerator = function*() {
yield 1;
yield 2;
};
const o = {[Symbol.asyncIterator]: syncGenerator};
for await (const x of o) {
}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorExplicitReturnType.ts | TypeScript | // @target: esnext
// @strictNullChecks: true
// @noImplicitReturns: true
// @noImplicitAny: true
function* g1(): Generator<number, boolean, string> {
yield; // error
yield "a"; // error
const x: number = yield 1; // error
return 10; // error
}
function* g2(): Generator<number, boolean, string> {
const x = yield 1;
return true;
}
declare const generator: Generator<number, symbol, string>;
function* g3(): Generator<number, boolean, string> {
const x: number = yield* generator; // error
return true;
}
function* g4(): Generator<number, boolean, string> {
const x = yield* generator;
return true;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorImplicitAny.ts | TypeScript | // @target: esnext
// @strictNullChecks: true
// @noImplicitReturns: true
// @noImplicitAny: true
function* g() {}
// https://github.com/microsoft/TypeScript/issues/35105
declare function noop(): void;
declare function f<T>(value: T): void;
function* g2() {
const value = yield; // error: implicit any
}
function* g3() {
const value: string = yield; // ok, contextually typed by `value`.
}
function* g4() {
yield; // ok, result is unused
yield, noop(); // ok, result is unused
noop(), yield, noop(); // ok, result is unused
(yield); // ok, result is unused
(yield, noop()), noop(); // ok, result is unused
for(yield; false; yield); // ok, results are unused
void (yield); // ok, results are unused
}
function* g5() {
f(yield); // error: implicit any
}
function* g6() {
f<string>(yield); // ok, contextually typed by f<string>
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorInAmbientContext5.ts | TypeScript | //@target: ES6
//@declaration: true
class C {
*generator(): any { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorInAmbientContext6.ts | TypeScript | //@target: ES6
//@declaration: true
module M {
export function *generator(): any { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorNoImplicitReturns.ts | TypeScript | // @target: esnext
// @noImplicitReturns: true
// @strictNullChecks: false
function* testGenerator () {
if (Math.random() > 0.5) {
return;
}
yield 'hello';
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorOverloads4.ts | TypeScript | //@target: ES6
class C {
f(s: string): Iterable<any>;
f(s: number): Iterable<any>;
*f(s: any): Iterable<any> { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorOverloads5.ts | TypeScript | //@target: ES6
module M {
function f(s: string): Iterable<any>;
function f(s: number): Iterable<any>;
function* f(s: any): Iterable<any> { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorReturnContextualType.ts | TypeScript | // @target: esnext
// @strict: true
// #35995
function* f1(): Generator<any, { x: 'x' }, any> {
return { x: 'x' };
}
function* g1(): Iterator<any, { x: 'x' }, any> {
return { x: 'x' };
}
async function* f2(): AsyncGenerator<any, { x: 'x' }, any> {
return { x: 'x' };
}
async function* g2(): AsyncIterator<any, { x: 'x' }, any> {
return { x: 'x' };
}
async function* f3(): AsyncGenerator<any, { x: 'x' }, any> {
return Promise.resolve({ x: 'x' });
}
async function* g3(): AsyncIterator<any, { x: 'x' }, any> {
return Promise.resolve({ x: 'x' });
}
async function* f4(): AsyncGenerator<any, { x: 'x' }, any> {
const ret = { x: 'x' };
return Promise.resolve(ret); // Error
}
async function* g4(): AsyncIterator<any, { x: 'x' }, any> {
const ret = { x: 'x' };
return Promise.resolve(ret); // Error
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorReturnTypeFallback.1.ts | TypeScript | // @target: esnext
// @lib: es5,es2015.iterable
// @noemit: true
// @strict: true
// Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode.
function* f() {
yield 1;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorReturnTypeFallback.2.ts | TypeScript | // @target: esnext
// @lib: es5
// @noemit: true
// @strict: true
// Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode.
// Report an error if IterableIterator cannot be found.
function* f() {
yield 1;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorReturnTypeFallback.3.ts | TypeScript | // @target: esnext
// @lib: es5,es2015.iterable
// @noemit: true
// @strict: true
// Do not allow generators to fallback to IterableIterator while in strictNullChecks mode if they need a type for the sent value.
// NOTE: In non-strictNullChecks mode, `undefined` (the default sent value) is assignable to everything.
function* f() {
const x: string = yield 1;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorReturnTypeFallback.4.ts | TypeScript | // @target: esnext
// @lib: es5,es2015.iterable
// @noemit: true
// @strict: false
// Allow generators to fallback to IterableIterator if they are not in strictNullChecks mode
// NOTE: In non-strictNullChecks mode, `undefined` (the default sent value) is assignable to everything.
function* f() {
const x: string = yield 1;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorReturnTypeFallback.5.ts | TypeScript | // @target: esnext
// @lib: es5,es2015.iterable
// @noemit: true
// @strict: true
// Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode.
function* f(): IterableIterator<number> {
yield 1;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorReturnTypeIndirectReferenceToGlobalType.ts | TypeScript | // @strict: true
// @target: esnext
interface I1 extends Iterator<0, 1, 2> {}
function* f1(): I1 {
const a = yield 0;
return 1;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorReturnTypeInference.ts | TypeScript | // @target: esnext
// @strictNullChecks: true
// @noImplicitReturns: true
// @noImplicitAny: true
declare const iterableIterator: IterableIterator<number>;
declare const generator: Generator<number, string, boolean>;
declare const never: never;
function* g000() { // Generator<never, void, unknown>
}
// 'yield' iteration type inference
function* g001() { // Generator<undefined, void, unknown>
yield;
}
function* g002() { // Generator<number, void, unknown>
yield 1;
}
function* g003() { // Generator<never, void, undefined>
yield* [];
}
function* g004() { // Generator<number, void, undefined>
yield* iterableIterator;
}
function* g005() { // Generator<number, void, boolean>
const x = yield* generator;
}
function* g006() { // Generator<1 | 2, void, unknown>
yield 1;
yield 2;
}
function* g007() { // Generator<never, void, unknown>
yield never;
}
// 'return' iteration type inference
function* g102() { // Generator<never, number, unknown>
return 1;
}
function* g103() { // Generator<never, 1 | 2, unknown>
if (Math.random()) return 1;
return 2;
}
function* g104() { // Generator<never, never, unknown>
return never;
}
// 'next' iteration type inference
function* g201() { // Generator<number, void, string>
let a: string = yield 1;
}
function* g202() { // Generator<1 | 2, void, never>
let a: string = yield 1;
let b: number = yield 2;
}
declare function f1(x: string): void;
declare function f1(x: number): void;
function* g203() { // Generator<number, void, string>
const x = f1(yield 1);
}
declare function f2<T>(x: T): T;
function* g204() { // Generator<number, void, any>
const x = f2(yield 1);
}
// mixed iteration types inference
function* g301() { // Generator<undefined, void, unknown>
yield;
return;
}
function* g302() { // Generator<number, void, unknown>
yield 1;
return;
}
function* g303() { // Generator<undefined, string, unknown>
yield;
return "a";
}
function* g304() { // Generator<number, string, unknown>
yield 1;
return "a";
}
function* g305() { // Generator<1 | 2, "a" | "b", unknown>
if (Math.random()) yield 1;
yield 2;
if (Math.random()) return "a";
return "b";
}
function* g306() { // Generator<number, boolean, "hi">
const a: "hi" = yield 1;
return true;
}
function* g307<T>() { // Generator<number, T, T>
const a: T = yield 0;
return a;
}
function* g308<T>(x: T) { // Generator<T, T, T>
const a: T = yield x;
return a;
}
function* g309<T, U, V>(x: T, y: U) { // Generator<T, U, V>
const a: V = yield x;
return y;
}
function* g310() { // Generator<undefined, void, [(1 | undefined)?, (2 | undefined)?]>
const [a = 1, b = 2] = yield;
}
function* g311() { // Generator<undefined, void, string>
yield* (function*() {
const y: string = yield;
})();
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorReturnTypeInferenceNonStrict.ts | TypeScript | // @target: esnext
// @strictNullChecks: false
// @noImplicitReturns: true
// @noImplicitAny: true
declare const iterableIterator: IterableIterator<number>;
declare const generator: Generator<number, string, boolean>;
declare const never: never;
function* g000() { // Generator<never, void, unknown>
}
// 'yield' iteration type inference
function* g001() { // Generator<any (implicit), void, unknown>
yield;
}
function* g002() { // Generator<number, void, unknown>
yield 1;
}
function* g003() { // Generator<any (implicit), void, unknown>
// NOTE: In strict mode, `[]` produces the type `never[]`.
// In non-strict mode, `[]` produces the type `undefined[]` which is implicitly any.
yield* [];
}
function* g004() { // Generator<number, void, undefined>
yield* iterableIterator;
}
function* g005() { // Generator<number, void, boolean>
const x = yield* generator;
}
function* g006() { // Generator<1 | 2, void, unknown>
yield 1;
yield 2;
}
function* g007() { // Generator<never, void, unknown>
yield never;
}
// 'return' iteration type inference
function* g102() { // Generator<never, number, unknown>
return 1;
}
function* g103() { // Generator<never, 1 | 2, unknown>
if (Math.random()) return 1;
return 2;
}
function* g104() { // Generator<never, never, unknown>
return never;
}
// 'next' iteration type inference
function* g201() { // Generator<number, void, string>
let a: string = yield 1;
}
function* g202() { // Generator<1 | 2, void, never>
let a: string = yield 1;
let b: number = yield 2;
}
declare function f1(x: string): void;
declare function f1(x: number): void;
function* g203() { // Generator<number, void, string>
const x = f1(yield 1);
}
declare function f2<T>(x: T): T;
function* g204() { // Generator<number, void, any>
const x = f2(yield 1);
}
// mixed iteration types inference
function* g301() { // Generator<any (implicit), void, unknown>
yield;
return;
}
function* g302() { // Generator<number, void, unknown>
yield 1;
return;
}
function* g303() { // Generator<any (implicit), string, unknown>
yield;
return "a";
}
function* g304() { // Generator<number, string, unknown>
yield 1;
return "a";
}
function* g305() { // Generator<1 | 2, "a" | "b", unknown>
if (Math.random()) yield 1;
yield 2;
if (Math.random()) return "a";
return "b";
}
function* g306() { // Generator<number, boolean, "hi">
const a: "hi" = yield 1;
return true;
}
function* g307<T>() { // Generator<number, T, T>
const a: T = yield 0;
return a;
}
function* g308<T>(x: T) { // Generator<T, T, T>
const a: T = yield x;
return a;
}
function* g309<T, U, V>(x: T, y: U) { // Generator<T, U, V>
const a: V = yield x;
return y;
}
function* g310() { // Generator<any (implicit), void, [(1 | undefined)?, (2 | undefined)?]>
const [a = 1, b = 2] = yield;
}
function* g311() { // Generator<any (implicit), void, string>
yield* (function*() {
const y: string = yield;
})();
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck1.ts | TypeScript | //@target: ES6
function* g1(): Iterator<string> { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck10.ts | TypeScript | //@target: ES6
function* g(): IterableIterator<any> {
return;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck11.ts | TypeScript | //@target: ES6
function* g(): IterableIterator<number> {
return 0;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck12.ts | TypeScript | //@target: ES6
function* g(): IterableIterator<number> {
return "";
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck13.ts | TypeScript | //@target: ES6
function* g(): IterableIterator<number> {
yield 0;
return "";
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck14.ts | TypeScript | //@target: ES6
function* g() {
yield 0;
return "";
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck15.ts | TypeScript | //@target: ES6
function* g() {
return "";
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck16.ts | TypeScript | //@target: ES6
function* g() {
return;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck17.ts | TypeScript | //@target: ES6
class Foo { x: number }
class Bar extends Foo { y: string }
function* g(): IterableIterator<Foo> {
yield;
yield new Bar;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck18.ts | TypeScript | //@target: ES6
class Foo { x: number }
class Baz { z: number }
function* g(): IterableIterator<Foo> {
yield;
yield new Baz;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck19.ts | TypeScript | //@target: ES6
class Foo { x: number }
class Bar extends Foo { y: string }
function* g(): IterableIterator<Foo> {
yield;
yield * [new Bar];
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck2.ts | TypeScript | //@target: ES6
function* g1(): Iterable<string> { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck20.ts | TypeScript | //@target: ES6
class Foo { x: number }
class Baz { z: number }
function* g(): IterableIterator<Foo> {
yield;
yield * [new Baz];
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck21.ts | TypeScript | //@target: ES6
class Foo { x: number }
class Bar extends Foo { y: string }
function* g(): IterableIterator<Foo> {
yield;
yield * new Bar;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck22.ts | TypeScript | //@target: ES6
class Foo { x: number }
class Bar extends Foo { y: string }
class Baz { z: number }
function* g3() {
yield;
yield new Bar;
yield new Baz;
yield *[new Bar];
yield *[new Baz];
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck23.ts | TypeScript | //@target: ES6
class Foo { x: number }
class Bar extends Foo { y: string }
class Baz { z: number }
function* g3() {
yield;
yield new Foo;
yield new Bar;
yield new Baz;
yield *[new Bar];
yield *[new Baz];
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck24.ts | TypeScript | //@target: ES6
class Foo { x: number }
class Bar extends Foo { y: string }
class Baz { z: number }
function* g3() {
yield;
yield * [new Foo];
yield new Bar;
yield new Baz;
yield *[new Bar];
yield *[new Baz];
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck25.ts | TypeScript | //@target: ES6
class Foo { x: number }
class Bar extends Foo { y: string }
class Baz { z: number }
var g3: () => Iterable<Foo> = function* () {
yield;
yield new Bar;
yield new Baz;
yield *[new Bar];
yield *[new Baz];
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck26.ts | TypeScript | //@target: ES6
function* g(): IterableIterator<(x: string) => number> {
yield x => x.length;
yield *[x => x.length];
return x => x.length;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck27.ts | TypeScript | //@target: ES6
function* g(): IterableIterator<(x: string) => number> {
yield * function* () {
yield x => x.length;
} ();
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck28.ts | TypeScript | //@target: ES6
function* g(): IterableIterator<(x: string) => number> {
yield * {
*[Symbol.iterator]() {
yield x => x.length;
}
};
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck29.ts | TypeScript | //@target: ES6
function* g2(): Iterator<Iterable<(x: string) => number>> {
yield function* () {
yield x => x.length;
} ()
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck3.ts | TypeScript | //@target: ES6
function* g1(): IterableIterator<string> { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck30.ts | TypeScript | //@target: ES6
function* g2(): Iterator<Iterable<(x: string) => number>> {
yield function* () {
yield x => x.length;
} ()
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck31.ts | TypeScript | //@target: ES6
function* g2(): Iterator<() => Iterable<(x: string) => number>> {
yield function* () {
yield x => x.length;
} ()
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck33.ts | TypeScript | //@target: ES6
function* g() {
yield 0;
function* g2() {
yield "";
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck34.ts | TypeScript | //@target: ES6
function* g() {
yield 0;
function* g2() {
return "";
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck35.ts | TypeScript | //@target: ES6
function* g() {
yield 0;
function g2() {
return "";
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck36.ts | TypeScript | //@target: ES6
function* g() {
yield yield 0;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck37.ts | TypeScript | //@target: ES6
function* g() {
return yield yield 0;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck38.ts | TypeScript | //@target: ES6
var yield;
function* g() {
yield 0;
var v: typeof yield;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck4.ts | TypeScript | //@target: ES6
function* g1(): {} { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck40.ts | TypeScript | //@target: ES6
function* g() {
class C extends (yield 0) { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck41.ts | TypeScript | //@target: ES6
function* g() {
let x = {
[yield 0]: 0
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck42.ts | TypeScript | //@target: ES6
function* g() {
let x = {
[yield 0]() {
}
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck43.ts | TypeScript | //@target: ES6
function* g() {
let x = {
*[yield 0]() {
}
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck44.ts | TypeScript | //@target: ES6
function* g() {
let x = {
get [yield 0]() {
return 0;
}
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck45.ts | TypeScript | //@target: ES6
declare function foo<T, U>(x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) => T): T;
foo("", function* () { yield x => x.length }, p => undefined); // T is fixed, should be string | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck46.ts | TypeScript | //@target: ES6
declare function foo<T, U>(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) => T): T;
foo("", function* () {
yield* {
*[Symbol.iterator]() {
yield x => x.length
}
}
}, p => undefined); // T is fixed, should be string | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck47.ts | TypeScript | //@target: ES6
//@noImplicitAny: true
function* g() { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck48.ts | TypeScript | //@target: ES6
//@noImplicitAny: true
function* g() {
yield;
}
function* h() {
yield undefined;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck49.ts | TypeScript | //@target: ES6
//@noImplicitAny: true
function* g() {
yield 0;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck5.ts | TypeScript | //@target: ES6
function* g1(): any { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck50.ts | TypeScript | //@target: ES6
//@noImplicitAny: true
function* g() {
yield yield;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck51.ts | TypeScript | //@target: ES6
//@noImplicitAny: true
function* g() {
function* h() {
yield 0;
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck52.ts | TypeScript | //@target: ES6
class Foo { x: number }
class Baz { z: number }
function* g() {
yield new Foo;
yield new Baz;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck53.ts | TypeScript | //@target: ES6
class Foo { x: number }
class Baz { z: number }
function* g() {
yield new Foo;
yield* [new Baz];
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck54.ts | TypeScript | //@target: ES6
class Foo { x: number }
class Baz { z: number }
function* g() {
yield* [new Foo];
yield* [new Baz];
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck55.ts | TypeScript | //@target: ES6
function* g() {
var x = class C extends (yield) {};
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck56.ts | TypeScript | //@target: ES6
function* g() {
var x = class C {
*[yield 0]() {
yield 0;
}
};
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck59.ts | TypeScript | // @target: ES6
// @experimentalDecorators: true
function* g() {
class C {
@(yield "")
m() { }
};
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck6.ts | TypeScript | //@target: ES6
function* g1(): number { } | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck60.ts | TypeScript | //@target: ES6
function* g() {
class C extends (yield) {};
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck61.ts | TypeScript | // @target: ES6
// @experimentalDecorators: true
function * g() {
@(yield 0)
class C {};
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck62.ts | TypeScript | // @module: commonjs
// @target: es6
// @noImplicitAny: true
export interface StrategicState {
lastStrategyApplied?: string;
}
export function strategy<T extends StrategicState>(stratName: string, gen: (a: T) => IterableIterator<T | undefined>): (a: T) => IterableIterator<T | undefined> {
return function*(state) {
for (const next of gen(state)) {
if (next) {
next.lastStrategyApplied = stratName;
}
yield next;
}
}
}
export interface Strategy<T> {
(a: T): IterableIterator<T | undefined>;
}
export interface State extends StrategicState {
foo: number;
}
export const Nothing1: Strategy<State> = strategy("Nothing", function*(state: State) {
return state;
});
export const Nothing2: Strategy<State> = strategy("Nothing", function*(state: State) {
yield state;
});
export const Nothing3: Strategy<State> = strategy("Nothing", function* (state: State) {
yield ;
return state;
});
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/generatorTypeCheck63.ts | TypeScript | // @module: commonjs
// @target: es6
// @noImplicitAny: true
export interface StrategicState {
lastStrategyApplied?: string;
}
export function strategy<T extends StrategicState>(stratName: string, gen: (a: T) => IterableIterator<T | undefined>): (a: T) => IterableIterator<T | undefined> {
return function*(state) {
for (const next of gen(state)) {
if (next) {
next.lastStrategyApplied = stratName;
}
yield next;
}
}
}
export interface Strategy<T> {
(a: T): IterableIterator<T | undefined>;
}
export interface State extends StrategicState {
foo: number;
}
export const Nothing: Strategy<State> = strategy("Nothing", function* (state: State) {
yield 1;
return state;
});
export const Nothing1: Strategy<State> = strategy("Nothing", function* (state: State) {
});
export const Nothing2: Strategy<State> = strategy("Nothing", function* (state: State) {
return 1;
});
export const Nothing3: Strategy<State> = strategy("Nothing", function* (state: State) {
yield state;
return 1;
}); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.