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/additionOperatorWithNullValueAndInvalidOperator.ts
TypeScript
// If one operand is the null or undefined value, it is treated as having the type of the other operand. function foo(): void { return undefined } var a: boolean; var b: Object; var c: void; var d: Number; // null + boolean/Object var r1 = null + a; var r2 = null + b; var r3 = null + c; var r4 = a + null; var r5 = b + null; var r6 = null + c; // other cases var r7 = null + d; var r8 = null + true; var r9 = null + { a: '' }; var r10 = null + foo(); var r11 = null + (() => { });
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/additionOperatorWithNullValueAndValidOperator.ts
TypeScript
// If one operand is the null or undefined value, it is treated as having the type of the other operand. enum E { a, b, c } var a: any; var b: number; var c: E; var d: string; // null + any var r1: any = null + a; var r2: any = a + null; // null + number/enum var r3 = null + b; var r4 = null + 1; var r5 = null + c; var r6 = null + E.a; var r7 = null + E['a']; var r8 = b + null; var r9 = 1 + null; var r10 = c + null var r11 = E.a + null; var r12 = E['a'] + null; // null + string var r13 = null + d; var r14 = null + ''; var r15 = d + null; var r16 = '' + null;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/additionOperatorWithNumberAndEnum.ts
TypeScript
enum E { a, b } enum F { c, d } var a: number; var b: E; var c: E | F; var r1 = a + a; var r2 = a + b; var r3 = b + a; var r4 = b + b; var r5 = 0 + a; var r6 = E.a + 0; var r7 = E.a + E.b; var r8 = E['a'] + E['b']; var r9 = E['a'] + F['c']; var r10 = a + c; var r11 = c + a; var r12 = b + c; var r13 = c + b; var r14 = c + c;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/additionOperatorWithOnlyNullValueOrUndefinedValue.ts
TypeScript
// bug 819721 var r1 = null + null; var r2 = null + undefined; var r3 = undefined + null; var r4 = undefined + undefined;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/additionOperatorWithStringAndEveryType.ts
TypeScript
enum E { a, b, c } var a: any; var b: boolean; var c: number; var d: string; var e: Object; var f: void; var g: E; var x: string; // string could plus every type, and the result is always string // string as left operand var r1 = x + a; var r2 = x + b; var r3 = x + c; var r4 = x + d; var r5 = x + e; var r6 = x + f; var r7 = x + g; // string as right operand var r8 = a + x; var r9 = b + x; var r10 = c + x; var r11 = d + x; var r12 = e + x; var r13 = f + x; var r14 = g + x; // other cases var r15 = x + E; var r16 = x + E.a; var r17 = x + ''; var r18 = x + 0; var r19 = x + { a: '' }; var r20 = x + [];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/additionOperatorWithTypeParameter.ts
TypeScript
// type parameter type is not a valid operand of addition operator enum E { a, b } function foo<T, U>(t: T, u: U) { var a: any; var b: boolean; var c: number; var d: string; var e: Object; var g: E; var f: void; // type parameter as left operand var r1: any = t + a; // ok, one operand is any var r2 = t + b; var r3 = t + c; var r4 = t + d; // ok, one operand is string var r5 = t + e; var r6 = t + g; var r7 = t + f; // type parameter as right operand var r8 = a + t; // ok, one operand is any var r9 = b + t; var r10 = c + t; var r11 = d + t; // ok, one operand is string var r12 = e + t; var r13 = g + t; var r14 = f + t; // other cases var r15 = t + null; var r16 = t + undefined; var r17 = t + t; var r18 = t + u; var r19 = t + (() => { }); var r20 = t + []; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/additionOperatorWithUndefinedValueAndInvalidOperands.ts
TypeScript
// If one operand is the null or undefined value, it is treated as having the type of the other operand. function foo(): void { return undefined } var a: boolean; var b: Object; var c: void; var d: Number; // undefined + boolean/Object var r1 = undefined + a; var r2 = undefined + b; var r3 = undefined + c; var r4 = a + undefined; var r5 = b + undefined; var r6 = undefined + c; // other cases var r7 = undefined + d; var r8 = undefined + true; var r9 = undefined + { a: '' }; var r10 = undefined + foo(); var r11 = undefined + (() => { });
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/additionOperatorWithUndefinedValueAndValidOperator.ts
TypeScript
// If one operand is the null or undefined value, it is treated as having the type of the other operand. enum E { a, b, c } var a: any; var b: number; var c: E; var d: string; // undefined + any var r1: any = undefined + a; var r2: any = a + undefined; // undefined + number/enum var r3 = undefined + b; var r4 = undefined + 1; var r5 = undefined + c; var r6 = undefined + E.a; var r7 = undefined + E['a']; var r8 = b + undefined; var r9 = 1 + undefined; var r10 = c + undefined var r11 = E.a + undefined; var r12 = E['a'] + undefined; // undefined + string var r13 = undefined + d; var r14 = undefined + ''; var r15 = d + undefined; var r16 = '' + undefined;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/allowImportingTsExtensions.ts
TypeScript
// @allowImportingTsExtensions: true // @noEmit: true // @moduleResolution: classic,node10,node16,nodenext,bundler // @jsx: preserve // @noTypesAndSymbols: true // @Filename: /ts.ts export {}; // @Filename: /tsx.tsx export {}; // @Filename: /dts.d.ts export {}; // @Filename: /b.ts import {} from "./ts.js"; import {} from "./ts.ts"; import type {} from "./ts.d.ts"; import {} from "./tsx.js"; import {} from "./tsx.jsx"; import {} from "./tsx.ts"; import {} from "./tsx.tsx"; import type {} from "./tsx.d.ts"; import {} from "./dts.js"; import {} from "./dts.ts"; import type {} from "./dts.d.ts"; // @Filename: /c.ts import {} from "./thisfiledoesnotexist.ts";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/allowImportingTypesDtsExtension.ts
TypeScript
// @allowImportingTsExtensions: true,false // @noEmit: true // @moduleResolution: classic,node10,node16,nodenext // @noTypesAndSymbols: true // @Filename: /types.d.ts export declare type User = { name: string; } // @Filename: /a.ts import type { User } from "./types.d.ts"; export type { User } from "./types.d.ts"; export const user: User = { name: "John" }; export function getUser(): import("./types.d.ts").User { return user; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/allowUnescapedParagraphAndLineSeparatorsInStringLiteral.ts
TypeScript
// Strings containing unescaped line / paragraph separators // Using both single quotes, double quotes and template literals var stringContainingUnescapedLineSeparator1 = "
STRING_CONTENT
"; var stringContainingUnescapedParagraphSeparator1 = "
STRING_CONTENT
"; var stringContainingUnescapedLineSeparator2 = '
STRING_CONTENT
'; var stringContainingUnescapedParagraphSeparator2 = '
STRING_CONTENT
'; var stringContainingUnescapedLineSeparator3 = `
STRING_CONTENT
`; var stringContainingUnescapedParagraphSeparator3 = `
STRING_CONTENT
`; // Array of unescaped line / paragraph separators var arr = [ "

STRING_CONTENT

", "


STRING_CONTENT


", "STRING_CONTENT
", "
STRING_CONTENT", `\
`, '
' ];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/allowsImportingTsExtension.ts
TypeScript
// @allowImportingTsExtensions: false // @target: esnext // @module: esnext // @Filename: a.ts export class A {} // @Filename: a.d.ts export class A {} // @Filename: b.ts import type { A } from "./a.ts"; // ok import {} from "./a.ts"; // error import { type A as _A } from "./a.ts"; // error type __A = import("./a.ts").A; // ok const aPromise = import("./a.ts"); // error // @Filename: c.ts import type { A } from "./a.d.ts"; // ok import {} from "./a.d.ts"; // error import { type A as _A } from "./a.d.ts"; // error type __A = import("./a.d.ts").A; // ok const aPromise = import("./a.d.ts"); // error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambient.ts
TypeScript
// @Filename: /a.ts export class A { a!: string } // @Filename: /b.ts import type { A } from './a'; declare class B extends A {} declare namespace ns { class C extends A {} }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientAccessors.ts
TypeScript
// @target: es5 // @declaration: true // ok to use accessors in ambient class in ES3 declare class C { static get a(): string; static set a(value: string); private static get b(): string; private static set b(foo: string); get x(): string; set x(value: string); private get y(): string; private set y(foo: string); }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientDeclarations.ts
TypeScript
// Ambient variable without type annotation declare var n; // Ambient variable with type annotation declare var m: string; // Ambient function with no type annotations declare function fn1(); // Ambient function with type annotations declare function fn2(n: string): number; // Ambient function with valid overloads declare function fn3(n: string): number; declare function fn4(n: number, y: number): string; // Ambient function with optional parameters declare function fn5(x, y?); declare function fn6(e?); declare function fn7(x, y?, ...z); declare function fn8(y?, ...z: number[]); declare function fn9(...q: {}[]); declare function fn10<T>(...q: T[]); // Ambient class declare class cls { constructor(); method(): cls; static static(p): number; static q; private fn(); private static fns(); } // Ambient enum declare enum E1 { x, y, z } // Ambient enum with integer literal initializer declare enum E2 { q, a = 1, b, c = 2, d } // Ambient enum members are always exported with or without export keyword declare enum E3 { A } declare module E3 { var B; } var x = E3.B; // Ambient module declare module M1 { var x; function fn(): number; } // Ambient module members are always exported with or without export keyword var p = M1.x; var q = M1.fn(); // Ambient external module in the global module // Ambient external module with a string literal name that is a top level external module name declare module 'external1' { var q; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientDeclarationsExternal.ts
TypeScript
//@Filename: decls.ts // Ambient external module with export assignment declare module 'equ' { var x; export = x; } declare module 'equ2' { var x: number; } // Ambient external import declaration referencing ambient external module using top level module name //@Filename: consumer.ts /// <reference path="decls.ts" /> import imp1 = require('equ'); // Ambient external module members are always exported with or without export keyword when module lacks export assignment import imp3 = require('equ2'); var n = imp3.x; var n: number;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns.ts
TypeScript
// @Filename: declarations.d.ts declare module "foo*baz" { export function foo(s: string): void; } // Augmentations still work declare module "foo*baz" { export const baz: string; } // Longest prefix wins declare module "foos*" { export const foos: string; } declare module "*!text" { const x: string; export default x; } // @Filename: user.ts ///<reference path="declarations.d.ts" /> import {foo, baz} from "foobarbaz"; foo(baz); import {foos} from "foosball"; foo(foos); // Works with relative file name import fileText from "./file!text"; foo(fileText);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging1.ts
TypeScript
// @filename: types.ts declare module "*.foo" { let everywhere: string; } // @filename: testA.ts import { everywhere, onlyInA } from "a.foo"; declare module "a.foo" { let onlyInA: number; } // @filename: testB.ts import { everywhere, onlyInA } from "b.foo"; // Error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging2.ts
TypeScript
// @filename: types.ts declare module "*.foo" { let everywhere: string; } // @filename: testA.ts import { everywhere, onlyInA, alsoOnlyInA } from "a.foo"; declare module "a.foo" { let onlyInA: number; } // @filename: testB.ts import { everywhere, onlyInA, alsoOnlyInA } from "b.foo"; // Error declare module "a.foo" { let alsoOnlyInA: number; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging3.ts
TypeScript
// @filename: types.ts declare module "*.foo" { export interface OhNo { star: string } } // @filename: test.ts declare module "a.foo" { export interface OhNo { a: string } } import { OhNo } from "b.foo" declare let ohno: OhNo; ohno.a // oh no
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_tooManyAsterisks.ts
TypeScript
declare module "too*many*asterisks" { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientEnumDeclaration1.ts
TypeScript
// In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions. declare enum E { a = 10, b = 10 + 1, c = b, d = (c) + 1, e = 10 << 2 * 8, }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientEnumDeclaration2.ts
TypeScript
// In ambient enum declarations that specify no const modifier, enum member declarations // that omit a value are considered computed members (as opposed to having auto- incremented values assigned). declare enum E { a, // E.a b, // E.b } declare const enum E1 { a, // E.a = 0 b, // E.b = 1 }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientExternalModuleInsideNonAmbient.ts
TypeScript
module M { export declare module "M" { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientExternalModuleInsideNonAmbientExternalModule.ts
TypeScript
//@module: amd export declare module "M" { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientExternalModuleMerging.ts
TypeScript
//@filename: ambientExternalModuleMerging_use.ts //@module: amd import M = require("M"); // Should be strings var x = M.x; var y = M.y; //@filename: ambientExternalModuleMerging_declare.ts declare module "M" { export var x: string; } // Merge declare module "M" { export var y: string; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientInsideNonAmbient.ts
TypeScript
module M { export declare var x; export declare function f(); export declare class C { } export declare enum E { } export declare module M { } } module M2 { declare var x; declare function f(); declare class C { } declare enum E { } declare module M { } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientInsideNonAmbientExternalModule.ts
TypeScript
// @module: amd export declare var x; export declare function f(); export declare class C { } export declare enum E { } export declare module M { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientShorthand.ts
TypeScript
// @Filename: declarations.d.ts declare module "jquery" // Semicolon is optional declare module "fs"; // @Filename: user.ts ///<reference path="declarations.d.ts"/> import foo, {bar} from "jquery"; import * as baz from "fs"; import boom = require("jquery"); foo(bar, baz, boom);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientShorthand_declarationEmit.ts
TypeScript
// @declaration: true declare module "foo";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientShorthand_duplicate.ts
TypeScript
// @Filename: declarations1.d.ts declare module "foo"; // @Filename: declarations2.d.ts declare module "foo"; // @Filename: user.ts ///<reference path="declarations1.d.ts" /> ///<reference path="declarations1.d.ts" /> import foo from "foo";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientShorthand_merging.ts
TypeScript
// @Filename: declarations1.d.ts declare module "foo"; // @Filename: declarations2.d.ts declare module "foo" { export const bar: number; } // @Filename: user.ts ///<reference path="declarations1.d.ts" /> ///<reference path="declarations1.d.ts" /> import foo, {bar} from "foo";
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/ambientShorthand_reExport.ts
TypeScript
// @Filename: declarations.d.ts declare module "jquery"; // @Filename: reExportX.ts export {x} from "jquery"; // @Filename: reExportAll.ts export * from "jquery"; // @Filename: reExportUser.ts import {x} from "./reExportX"; import * as $ from "./reExportAll"; // '$' is not callable, it is an object. x($);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/amdImportAsPrimaryExpression.ts
TypeScript
// @module: amd // @Filename: foo_0.ts export enum E1 { A,B,C } // @Filename: foo_1.ts import foo = require("./foo_0"); if(foo.E1.A === 0){ // Should cause runtime import - interesting optimization possibility, as gets inlined to 0. }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/amdImportNotAsPrimaryExpression.ts
TypeScript
// @module: amd // @Filename: foo_0.ts export class C1 { m1 = 42; static s1 = true; } export interface I1 { name: string; age: number; } export module M1 { export interface I2 { foo: string; } } export enum E1 { A,B,C } // @Filename: foo_1.ts import foo = require("./foo_0"); // None of the below should cause a runtime dependency on foo_0 import f = foo.M1; var i: f.I2; var x: foo.C1 = <{m1: number}>{}; var y: typeof foo.C1.s1 = false; var z: foo.M1.I2; var e: number = <foo.E1>0;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/annotatedThisPropertyInitializerDoesntNarrow.ts
TypeScript
// @noEmit: true // @allowJs: true // @checkJs: true // @Filename: Compilation.js // from webpack/lib/Compilation.js and filed at #26427 /** @param {{ [s: string]: number }} map */ function mappy(map) {} export class C { constructor() { /** @type {{ [assetName: string]: number}} */ this.assets = {}; } m() { mappy(this.assets) } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/anonymousDefaultExportsAmd.ts
TypeScript
// @target: ES6 // @module: amd // @filename: a.ts export default class {} // @filename: b.ts export default function() {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/anonymousDefaultExportsCommonjs.ts
TypeScript
// @target: ES6 // @module: commonjs // @filename: a.ts export default class {} // @filename: b.ts export default function() {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/anonymousDefaultExportsSystem.ts
TypeScript
// @target: ES6 // @module: system // @filename: a.ts export default class {} // @filename: b.ts export default function() {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/anonymousDefaultExportsUmd.ts
TypeScript
// @target: ES6 // @module: umd // @filename: a.ts export default class {} // @filename: b.ts export default function() {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/anyAsConstructor.ts
TypeScript
// any is considered an untyped function call // can be called except with type arguments which is an error var x: any; var a = new x(); var b = new x('hello'); var c = new x(x); // grammar allows this for constructors var d = new x<any>(x); // no error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/anyAsFunctionCall.ts
TypeScript
// any is considered an untyped function call // can be called except with type arguments which is an error var x: any; var a = x(); var b = x('hello'); var c = x(x);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/anyAsGenericFunctionCall.ts
TypeScript
// any is considered an untyped function call // can be called except with type arguments which is an error var x: any; var a = x<number>(); var b = x<string>('hello'); class C { foo: string; } var c = x<C>(x); var d = x<any>(x);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/anyAssignabilityInInheritance.ts
TypeScript
// any is not a subtype of any other types, errors expected on all the below derived classes unless otherwise noted interface I { [x: string]: any; foo: any; // ok, any identical to itself } var a: any; declare function foo2(x: number): number; declare function foo2(x: any): any; var r3 = foo2(a); // any, not a subtype of number so it skips that overload, is a subtype of itself so it picks second (if truly ambiguous it would pick first overload) declare function foo3(x: string): string; declare function foo3(x: any): any; var r3 = foo3(a); // any declare function foo4(x: boolean): boolean; declare function foo4(x: any): any; var r3 = foo3(a); // any declare function foo5(x: Date): Date; declare function foo5(x: any): any; var r3 = foo3(a); // any declare function foo6(x: RegExp): RegExp; declare function foo6(x: any): any; var r3 = foo3(a); // any declare function foo7(x: { bar: number }): { bar: number }; declare function foo7(x: any): any; var r3 = foo3(a); // any declare function foo8(x: number[]): number[]; declare function foo8(x: any): any; var r3 = foo3(a); // any interface I8 { foo: string } declare function foo9(x: I8): I8; declare function foo9(x: any): any; var r3 = foo3(a); // any class A { foo: number; } declare function foo10(x: A): A; declare function foo10(x: any): any; var r3 = foo3(a); // any class A2<T> { foo: T; } declare function foo11(x: A2<string>): A2<string>; declare function foo11(x: any): any; var r3 = foo3(a); // any declare function foo12(x: (x) => number): (x) => number; declare function foo12(x: any): any; var r3 = foo3(a); // any declare function foo13(x: <T>(x: T) => T): <T>(x: T) => T; declare function foo13(x: any): any; var r3 = foo3(a); // any enum E { A } declare function foo14(x: E): E; declare function foo14(x: any): any; var r3 = foo3(a); // any function f() { } module f { export var bar = 1; } declare function foo15(x: typeof f): typeof f; declare function foo15(x: any): any; var r3 = foo3(a); // any class CC { baz: string } module CC { export var bar = 1; } declare function foo16(x: CC): CC; declare function foo16(x: any): any; var r3 = foo3(a); // any declare function foo17(x: Object): Object; declare function foo17(x: any): any; var r3 = foo3(a); // any declare function foo18(x: {}): {}; declare function foo18(x: any): any; var r3 = foo3(a); // any
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/anyAssignableToEveryType.ts
TypeScript
var a: any; class C { foo: string; } var ac: C; interface I { foo: string; } var ai: I; enum E { A } var ae: E; var b: number = a; var c: string = a; var d: boolean = a; var e: Date = a; var f: any = a; var g: void = a; var h: Object = a; var i: {} = a; var j: () => {} = a; var k: Function = a; var l: (x: number) => string = a; ac = a; ai = a; ae = a; var m: number[] = a; var n: { foo: string } = a; var o: <T>(x: T) => T = a; var p: Number = a; var q: String = a; function foo<T, U /*extends T*/, V extends Date>(x: T, y: U, z: V) { x = a; y = a; z = a; } //function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) { // x = a; // y = a; // z = a; //}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/anyAssignableToEveryType2.ts
TypeScript
// any is not a subtype of any other types, but is assignable, all the below should work interface I { [x: string]: any; foo: any; // ok, any identical to itself } interface I2 { [x: string]: number; foo: any; } interface I3 { [x: string]: string; foo: any; } interface I4 { [x: string]: boolean; foo: any; } interface I5 { [x: string]: Date; foo: any; } interface I6 { [x: string]: RegExp; foo: any; } interface I7 { [x: string]: { bar: number }; foo: any; } interface I8 { [x: string]: number[]; foo: any; } interface I9 { [x: string]: I8; foo: any; } class A { foo: number; } interface I10 { [x: string]: A; foo: any; } class A2<T> { foo: T; } interface I11 { [x: string]: A2<number>; foo: any; } interface I12 { [x: string]: (x) => number; foo: any; } interface I13 { [x: string]: <T>(x: T) => T; foo: any; } enum E { A } interface I14 { [x: string]: E; foo: any; } function f() { } module f { export var bar = 1; } interface I15 { [x: string]: typeof f; foo: any; } class c { baz: string } module c { export var bar = 1; } interface I16 { [x: string]: typeof c; foo: any; } interface I17<T> { [x: string]: T; foo: any; } interface I18<T, U extends T> { [x: string]: U; foo: any; } interface I19 { [x: string]: Object; foo: any; } interface I20 { [x: string]: {}; foo: any; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/anyPropertyAccess.ts
TypeScript
var x: any; var a = x.foo; var b = x['foo']; var c = x['fn'](); var d = x.bar.baz; var e = x[0].foo; var f = x['0'].bar;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/apparentTypeSubtyping.ts
TypeScript
// subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: class Base<U extends String> { x: U; } // is String (S) a subtype of U extends String (T)? Would only be true if we used the apparent type of U (T) class Derived<U> extends Base<string> { // error x: String; } class Base2 { x: String; static s: String; } // is U extends String (S) a subtype of String (T)? Apparent type of U is String so it succeeds class Derived2<U extends String> extends Base2 { // error because of the prototype's not matching, not because of the instance side x: U; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/apparentTypeSupertype.ts
TypeScript
// subtype checks use the apparent type of the target type // S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: class Base { x: string; } // is String (S) a subtype of U extends String (T)? Would only be true if we used the apparent type of U (T) class Derived<U extends String> extends Base { // error x: U; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/argumentExpressionContextualTyping.ts
TypeScript
// In a typed function call, argument expressions are contextually typed by their corresponding parameter types. function foo({x: [a, b], y: {c, d, e}}) { } function bar({x: [a, b = 10], y: {c, d, e = { f:1 }}}) { } function baz(x: [string, number, boolean]) { } var o = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; var o1: { x: [string, number], y: { c: boolean, d: string, e: number } } = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; foo(o1); // Not error since x has contextual type of tuple namely [string, number] foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }); // Not error var array = ["string", 1, true]; var tuple: [string, number, boolean] = ["string", 1, true]; baz(tuple); baz(["string", 1, true]); baz(array); // Error baz(["string", 1, true, ...array]); // Error foo(o); // Error because x has an array type namely (string|number)[]
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arithmeticOperatorWithAnyAndNumber.ts
TypeScript
var a: any; var b: number; // operator * var ra1 = a * a; var ra2 = a * b; var ra3 = a * 0; var ra4 = 0 * a; var ra5 = 0 * 0; var ra6 = b * 0; var ra7 = 0 * b; var ra8 = b * b; // operator / var rb1 = a / a; var rb2 = a / b; var rb3 = a / 0; var rb4 = 0 / a; var rb5 = 0 / 0; var rb6 = b / 0; var rb7 = 0 / b; var rb8 = b / b; // operator % var rc1 = a % a; var rc2 = a % b; var rc3 = a % 0; var rc4 = 0 % a; var rc5 = 0 % 0; var rc6 = b % 0; var rc7 = 0 % b; var rc8 = b % b; // operator - var rd1 = a - a; var rd2 = a - b; var rd3 = a - 0; var rd4 = 0 - a; var rd5 = 0 - 0; var rd6 = b - 0; var rd7 = 0 - b; var rd8 = b - b; // operator << var re1 = a << a; var re2 = a << b; var re3 = a << 0; var re4 = 0 << a; var re5 = 0 << 0; var re6 = b << 0; var re7 = 0 << b; var re8 = b << b; // operator >> var rf1 = a >> a; var rf2 = a >> b; var rf3 = a >> 0; var rf4 = 0 >> a; var rf5 = 0 >> 0; var rf6 = b >> 0; var rf7 = 0 >> b; var rf8 = b >> b; // operator >>> var rg1 = a >>> a; var rg2 = a >>> b; var rg3 = a >>> 0; var rg4 = 0 >>> a; var rg5 = 0 >>> 0; var rg6 = b >>> 0; var rg7 = 0 >>> b; var rg8 = b >>> b; // operator & var rh1 = a & a; var rh2 = a & b; var rh3 = a & 0; var rh4 = 0 & a; var rh5 = 0 & 0; var rh6 = b & 0; var rh7 = 0 & b; var rh8 = b & b; // operator ^ var ri1 = a ^ a; var ri2 = a ^ b; var ri3 = a ^ 0; var ri4 = 0 ^ a; var ri5 = 0 ^ 0; var ri6 = b ^ 0; var ri7 = 0 ^ b; var ri8 = b ^ b; // operator | var rj1 = a | a; var rj2 = a | b; var rj3 = a | 0; var rj4 = 0 | a; var rj5 = 0 | 0; var rj6 = b | 0; var rj7 = 0 | b; var rj8 = b | b;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arithmeticOperatorWithEnum.ts
TypeScript
// operands of an enum type are treated as having the primitive type Number. enum E { a, b } var a: any; var b: number; var c: E; // operator * var ra1 = c * a; var ra2 = c * b; var ra3 = c * c; var ra4 = a * c; var ra5 = b * c; var ra6 = E.a * a; var ra7 = E.a * b; var ra8 = E.a * E.b; var ra9 = E.a * 1; var ra10 = a * E.b; var ra11 = b * E.b; var ra12 = 1 * E.b; // operator / var rb1 = c / a; var rb2 = c / b; var rb3 = c / c; var rb4 = a / c; var rb5 = b / c; var rb6 = E.a / a; var rb7 = E.a / b; var rb8 = E.a / E.b; var rb9 = E.a / 1; var rb10 = a / E.b; var rb11 = b / E.b; var rb12 = 1 / E.b; // operator % var rc1 = c % a; var rc2 = c % b; var rc3 = c % c; var rc4 = a % c; var rc5 = b % c; var rc6 = E.a % a; var rc7 = E.a % b; var rc8 = E.a % E.b; var rc9 = E.a % 1; var rc10 = a % E.b; var rc11 = b % E.b; var rc12 = 1 % E.b; // operator - var rd1 = c - a; var rd2 = c - b; var rd3 = c - c; var rd4 = a - c; var rd5 = b - c; var rd6 = E.a - a; var rd7 = E.a - b; var rd8 = E.a - E.b; var rd9 = E.a - 1; var rd10 = a - E.b; var rd11 = b - E.b; var rd12 = 1 - E.b; // operator << var re1 = c << a; var re2 = c << b; var re3 = c << c; var re4 = a << c; var re5 = b << c; var re6 = E.a << a; var re7 = E.a << b; var re8 = E.a << E.b; var re9 = E.a << 1; var re10 = a << E.b; var re11 = b << E.b; var re12 = 1 << E.b; // operator >> var rf1 = c >> a; var rf2 = c >> b; var rf3 = c >> c; var rf4 = a >> c; var rf5 = b >> c; var rf6 = E.a >> a; var rf7 = E.a >> b; var rf8 = E.a >> E.b; var rf9 = E.a >> 1; var rf10 = a >> E.b; var rf11 = b >> E.b; var rf12 = 1 >> E.b; // operator >>> var rg1 = c >>> a; var rg2 = c >>> b; var rg3 = c >>> c; var rg4 = a >>> c; var rg5 = b >>> c; var rg6 = E.a >>> a; var rg7 = E.a >>> b; var rg8 = E.a >>> E.b; var rg9 = E.a >>> 1; var rg10 = a >>> E.b; var rg11 = b >>> E.b; var rg12 = 1 >>> E.b; // operator & var rh1 = c & a; var rh2 = c & b; var rh3 = c & c; var rh4 = a & c; var rh5 = b & c; var rh6 = E.a & a; var rh7 = E.a & b; var rh8 = E.a & E.b; var rh9 = E.a & 1; var rh10 = a & E.b; var rh11 = b & E.b; var rh12 = 1 & E.b; // operator ^ var ri1 = c ^ a; var ri2 = c ^ b; var ri3 = c ^ c; var ri4 = a ^ c; var ri5 = b ^ c; var ri6 = E.a ^ a; var ri7 = E.a ^ b; var ri8 = E.a ^ E.b; var ri9 = E.a ^ 1; var ri10 = a ^ E.b; var ri11 = b ^ E.b; var ri12 = 1 ^ E.b; // operator | var rj1 = c | a; var rj2 = c | b; var rj3 = c | c; var rj4 = a | c; var rj5 = b | c; var rj6 = E.a | a; var rj7 = E.a | b; var rj8 = E.a | E.b; var rj9 = E.a | 1; var rj10 = a | E.b; var rj11 = b | E.b; var rj12 = 1 | E.b;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arithmeticOperatorWithEnumUnion.ts
TypeScript
// operands of an enum type are treated as having the primitive type Number. enum E { a, b } enum F { c, d } var a: any; var b: number; var c: E | F; // operator * var ra1 = c * a; var ra2 = c * b; var ra3 = c * c; var ra4 = a * c; var ra5 = b * c; var ra6 = E.a * a; var ra7 = E.a * b; var ra8 = E.a * E.b; var ra9 = E.a * 1; var ra10 = a * E.b; var ra11 = b * E.b; var ra12 = 1 * E.b; // operator / var rb1 = c / a; var rb2 = c / b; var rb3 = c / c; var rb4 = a / c; var rb5 = b / c; var rb6 = E.a / a; var rb7 = E.a / b; var rb8 = E.a / E.b; var rb9 = E.a / 1; var rb10 = a / E.b; var rb11 = b / E.b; var rb12 = 1 / E.b; // operator % var rc1 = c % a; var rc2 = c % b; var rc3 = c % c; var rc4 = a % c; var rc5 = b % c; var rc6 = E.a % a; var rc7 = E.a % b; var rc8 = E.a % E.b; var rc9 = E.a % 1; var rc10 = a % E.b; var rc11 = b % E.b; var rc12 = 1 % E.b; // operator - var rd1 = c - a; var rd2 = c - b; var rd3 = c - c; var rd4 = a - c; var rd5 = b - c; var rd6 = E.a - a; var rd7 = E.a - b; var rd8 = E.a - E.b; var rd9 = E.a - 1; var rd10 = a - E.b; var rd11 = b - E.b; var rd12 = 1 - E.b; // operator << var re1 = c << a; var re2 = c << b; var re3 = c << c; var re4 = a << c; var re5 = b << c; var re6 = E.a << a; var re7 = E.a << b; var re8 = E.a << E.b; var re9 = E.a << 1; var re10 = a << E.b; var re11 = b << E.b; var re12 = 1 << E.b; // operator >> var rf1 = c >> a; var rf2 = c >> b; var rf3 = c >> c; var rf4 = a >> c; var rf5 = b >> c; var rf6 = E.a >> a; var rf7 = E.a >> b; var rf8 = E.a >> E.b; var rf9 = E.a >> 1; var rf10 = a >> E.b; var rf11 = b >> E.b; var rf12 = 1 >> E.b; // operator >>> var rg1 = c >>> a; var rg2 = c >>> b; var rg3 = c >>> c; var rg4 = a >>> c; var rg5 = b >>> c; var rg6 = E.a >>> a; var rg7 = E.a >>> b; var rg8 = E.a >>> E.b; var rg9 = E.a >>> 1; var rg10 = a >>> E.b; var rg11 = b >>> E.b; var rg12 = 1 >>> E.b; // operator & var rh1 = c & a; var rh2 = c & b; var rh3 = c & c; var rh4 = a & c; var rh5 = b & c; var rh6 = E.a & a; var rh7 = E.a & b; var rh8 = E.a & E.b; var rh9 = E.a & 1; var rh10 = a & E.b; var rh11 = b & E.b; var rh12 = 1 & E.b; // operator ^ var ri1 = c ^ a; var ri2 = c ^ b; var ri3 = c ^ c; var ri4 = a ^ c; var ri5 = b ^ c; var ri6 = E.a ^ a; var ri7 = E.a ^ b; var ri8 = E.a ^ E.b; var ri9 = E.a ^ 1; var ri10 = a ^ E.b; var ri11 = b ^ E.b; var ri12 = 1 ^ E.b; // operator | var rj1 = c | a; var rj2 = c | b; var rj3 = c | c; var rj4 = a | c; var rj5 = b | c; var rj6 = E.a | a; var rj7 = E.a | b; var rj8 = E.a | E.b; var rj9 = E.a | 1; var rj10 = a | E.b; var rj11 = b | E.b; var rj12 = 1 | E.b;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arithmeticOperatorWithInvalidOperands.ts
TypeScript
// these operators require their operands to be of type Any, the Number primitive type, or // an enum type enum E { a, b, c } var a: any; var b: boolean; var c: number; var d: string; var e: { a: number }; var f: Number; // All of the below should be an error unless otherwise noted // operator * var r1a1 = a * a; //ok var r1a2 = a * b; var r1a3 = a * c; //ok var r1a4 = a * d; var r1a5 = a * e; var r1a6 = a * f; var r1b1 = b * a; var r1b2 = b * b; var r1b3 = b * c; var r1b4 = b * d; var r1b5 = b * e; var r1b6 = b * f; var r1c1 = c * a; //ok var r1c2 = c * b; var r1c3 = c * c; //ok var r1c4 = c * d; var r1c5 = c * e; var r1c6 = c * f; var r1d1 = d * a; var r1d2 = d * b; var r1d3 = d * c; var r1d4 = d * d; var r1d5 = d * e; var r1d6 = d * f; var r1e1 = e * a; var r1e2 = e * b; var r1e3 = e * c; var r1e4 = e * d; var r1e5 = e * e; var r1e6 = e * f; var r1f1 = f * a; var r1f2 = f * b; var r1f3 = f * c; var r1f4 = f * d; var r1f5 = f * e; var r1f6 = f * f; var r1g1 = E.a * a; //ok var r1g2 = E.a * b; var r1g3 = E.a * c; //ok var r1g4 = E.a * d; var r1g5 = E.a * e; var r1g6 = E.a * f; var r1h1 = a * E.b; //ok var r1h2 = b * E.b; var r1h3 = c * E.b; //ok var r1h4 = d * E.b; var r1h5 = e * E.b; var r1h6 = f * E.b; // operator / var r2a1 = a / a; //ok var r2a2 = a / b; var r2a3 = a / c; //ok var r2a4 = a / d; var r2a5 = a / e; var r2a6 = a / f; var r2b1 = b / a; var r2b2 = b / b; var r2b3 = b / c; var r2b4 = b / d; var r2b5 = b / e; var r2b6 = b / f; var r2c1 = c / a; //ok var r2c2 = c / b; var r2c3 = c / c; //ok var r2c4 = c / d; var r2c5 = c / e; var r2c6 = c / f; var r2d1 = d / a; var r2d2 = d / b; var r2d3 = d / c; var r2d4 = d / d; var r2d5 = d / e; var r2d6 = d / f; var r2e1 = e / a; var r2e2 = e / b; var r2e3 = e / c; var r2e4 = e / d; var r2e5 = e / e; var r2e6 = e / f; var r2f1 = f / a; var r2f2 = f / b; var r2f3 = f / c; var r2f4 = f / d; var r2f5 = f / e; var r2f6 = f / f; var r2g1 = E.a / a; //ok var r2g2 = E.a / b; var r2g3 = E.a / c; //ok var r2g4 = E.a / d; var r2g5 = E.a / e; var r2g6 = E.a / f; var r2h1 = a / E.b; //ok var r2h2 = b / E.b; var r2h3 = c / E.b; //ok var r2h4 = d / E.b; var r2h5 = e / E.b; var r2h6 = f / E.b; // operator % var r3a1 = a % a; //ok var r3a2 = a % b; var r3a3 = a % c; //ok var r3a4 = a % d; var r3a5 = a % e; var r3a6 = a % f; var r3b1 = b % a; var r3b2 = b % b; var r3b3 = b % c; var r3b4 = b % d; var r3b5 = b % e; var r3b6 = b % f; var r3c1 = c % a; //ok var r3c2 = c % b; var r3c3 = c % c; //ok var r3c4 = c % d; var r3c5 = c % e; var r3c6 = c % f; var r3d1 = d % a; var r3d2 = d % b; var r3d3 = d % c; var r3d4 = d % d; var r3d5 = d % e; var r3d6 = d % f; var r3e1 = e % a; var r3e2 = e % b; var r3e3 = e % c; var r3e4 = e % d; var r3e5 = e % e; var r3e6 = e % f; var r3f1 = f % a; var r3f2 = f % b; var r3f3 = f % c; var r3f4 = f % d; var r3f5 = f % e; var r3f6 = f % f; var r3g1 = E.a % a; //ok var r3g2 = E.a % b; var r3g3 = E.a % c; //ok var r3g4 = E.a % d; var r3g5 = E.a % e; var r3g6 = E.a % f; var r3h1 = a % E.b; //ok var r3h2 = b % E.b; var r3h3 = c % E.b; //ok var r3h4 = d % E.b; var r3h5 = e % E.b; var r3h6 = f % E.b; // operator - var r4a1 = a - a; //ok var r4a2 = a - b; var r4a3 = a - c; //ok var r4a4 = a - d; var r4a5 = a - e; var r4a6 = a - f; var r4b1 = b - a; var r4b2 = b - b; var r4b3 = b - c; var r4b4 = b - d; var r4b5 = b - e; var r4b6 = b - f; var r4c1 = c - a; //ok var r4c2 = c - b; var r4c3 = c - c; //ok var r4c4 = c - d; var r4c5 = c - e; var r4c6 = c - f; var r4d1 = d - a; var r4d2 = d - b; var r4d3 = d - c; var r4d4 = d - d; var r4d5 = d - e; var r4d6 = d - f; var r4e1 = e - a; var r4e2 = e - b; var r4e3 = e - c; var r4e4 = e - d; var r4e5 = e - e; var r4e6 = e - f; var r4f1 = f - a; var r4f2 = f - b; var r4f3 = f - c; var r4f4 = f - d; var r4f5 = f - e; var r4f6 = f - f; var r4g1 = E.a - a; //ok var r4g2 = E.a - b; var r4g3 = E.a - c; //ok var r4g4 = E.a - d; var r4g5 = E.a - e; var r4g6 = E.a - f; var r4h1 = a - E.b; //ok var r4h2 = b - E.b; var r4h3 = c - E.b; //ok var r4h4 = d - E.b; var r4h5 = e - E.b; var r4h6 = f - E.b; // operator << var r5a1 = a << a; //ok var r5a2 = a << b; var r5a3 = a << c; //ok var r5a4 = a << d; var r5a5 = a << e; var r5a6 = a << f; var r5b1 = b << a; var r5b2 = b << b; var r5b3 = b << c; var r5b4 = b << d; var r5b5 = b << e; var r5b6 = b << f; var r5c1 = c << a; //ok var r5c2 = c << b; var r5c3 = c << c; //ok var r5c4 = c << d; var r5c5 = c << e; var r5c6 = c << f; var r5d1 = d << a; var r5d2 = d << b; var r5d3 = d << c; var r5d4 = d << d; var r5d5 = d << e; var r5d6 = d << f; var r5e1 = e << a; var r5e2 = e << b; var r5e3 = e << c; var r5e4 = e << d; var r5e5 = e << e; var r5e6 = e << f; var r5f1 = f << a; var r5f2 = f << b; var r5f3 = f << c; var r5f4 = f << d; var r5f5 = f << e; var r5f6 = f << f; var r5g1 = E.a << a; //ok var r5g2 = E.a << b; var r5g3 = E.a << c; //ok var r5g4 = E.a << d; var r5g5 = E.a << e; var r5g6 = E.a << f; var r5h1 = a << E.b; //ok var r5h2 = b << E.b; var r5h3 = c << E.b; //ok var r5h4 = d << E.b; var r5h5 = e << E.b; var r5h6 = f << E.b; // operator >> var r6a1 = a >> a; //ok var r6a2 = a >> b; var r6a3 = a >> c; //ok var r6a4 = a >> d; var r6a5 = a >> e; var r6a6 = a >> f; var r6b1 = b >> a; var r6b2 = b >> b; var r6b3 = b >> c; var r6b4 = b >> d; var r6b5 = b >> e; var r6b6 = b >> f; var r6c1 = c >> a; //ok var r6c2 = c >> b; var r6c3 = c >> c; //ok var r6c4 = c >> d; var r6c5 = c >> e; var r6c6 = c >> f; var r6d1 = d >> a; var r6d2 = d >> b; var r6d3 = d >> c; var r6d4 = d >> d; var r6d5 = d >> e; var r6d6 = d >> f; var r6e1 = e >> a; var r6e2 = e >> b; var r6e3 = e >> c; var r6e4 = e >> d; var r6e5 = e >> e; var r6e6 = e >> f; var r6f1 = f >> a; var r6f2 = f >> b; var r6f3 = f >> c; var r6f4 = f >> d; var r6f5 = f >> e; var r6f6 = f >> f; var r6g1 = E.a >> a; //ok var r6g2 = E.a >> b; var r6g3 = E.a >> c; //ok var r6g4 = E.a >> d; var r6g5 = E.a >> e; var r6g6 = E.a >> f; var r6h1 = a >> E.b; //ok var r6h2 = b >> E.b; var r6h3 = c >> E.b; //ok var r6h4 = d >> E.b; var r6h5 = e >> E.b; var r6h6 = f >> E.b; // operator >>> var r7a1 = a >>> a; //ok var r7a2 = a >>> b; var r7a3 = a >>> c; //ok var r7a4 = a >>> d; var r7a5 = a >>> e; var r7a6 = a >>> f; var r7b1 = b >>> a; var r7b2 = b >>> b; var r7b3 = b >>> c; var r7b4 = b >>> d; var r7b5 = b >>> e; var r7b6 = b >>> f; var r7c1 = c >>> a; //ok var r7c2 = c >>> b; var r7c3 = c >>> c; //ok var r7c4 = c >>> d; var r7c5 = c >>> e; var r7c6 = c >>> f; var r7d1 = d >>> a; var r7d2 = d >>> b; var r7d3 = d >>> c; var r7d4 = d >>> d; var r7d5 = d >>> e; var r7d6 = d >>> f; var r7e1 = e >>> a; var r7e2 = e >>> b; var r7e3 = e >>> c; var r7e4 = e >>> d; var r7e5 = e >>> e; var r7e6 = e >>> f; var r7f1 = f >>> a; var r7f2 = f >>> b; var r7f3 = f >>> c; var r7f4 = f >>> d; var r7f5 = f >>> e; var r7f6 = f >>> f; var r7g1 = E.a >>> a; //ok var r7g2 = E.a >>> b; var r7g3 = E.a >>> c; //ok var r7g4 = E.a >>> d; var r7g5 = E.a >>> e; var r7g6 = E.a >>> f; var r7h1 = a >>> E.b; //ok var r7h2 = b >>> E.b; var r7h3 = c >>> E.b; //ok var r7h4 = d >>> E.b; var r7h5 = e >>> E.b; var r7h6 = f >>> E.b; // operator & var r8a1 = a & a; //ok var r8a2 = a & b; var r8a3 = a & c; //ok var r8a4 = a & d; var r8a5 = a & e; var r8a6 = a & f; var r8b1 = b & a; var r8b2 = b & b; var r8b3 = b & c; var r8b4 = b & d; var r8b5 = b & e; var r8b6 = b & f; var r8c1 = c & a; //ok var r8c2 = c & b; var r8c3 = c & c; //ok var r8c4 = c & d; var r8c5 = c & e; var r8c6 = c & f; var r8d1 = d & a; var r8d2 = d & b; var r8d3 = d & c; var r8d4 = d & d; var r8d5 = d & e; var r8d6 = d & f; var r8e1 = e & a; var r8e2 = e & b; var r8e3 = e & c; var r8e4 = e & d; var r8e5 = e & e; var r8e6 = e & f; var r8f1 = f & a; var r8f2 = f & b; var r8f3 = f & c; var r8f4 = f & d; var r8f5 = f & e; var r8f6 = f & f; var r8g1 = E.a & a; //ok var r8g2 = E.a & b; var r8g3 = E.a & c; //ok var r8g4 = E.a & d; var r8g5 = E.a & e; var r8g6 = E.a & f; var r8h1 = a & E.b; //ok var r8h2 = b & E.b; var r8h3 = c & E.b; //ok var r8h4 = d & E.b; var r8h5 = e & E.b; var r8h6 = f & E.b; // operator ^ var r9a1 = a ^ a; //ok var r9a2 = a ^ b; var r9a3 = a ^ c; //ok var r9a4 = a ^ d; var r9a5 = a ^ e; var r9a6 = a ^ f; var r9b1 = b ^ a; var r9b2 = b ^ b; var r9b3 = b ^ c; var r9b4 = b ^ d; var r9b5 = b ^ e; var r9b6 = b ^ f; var r9c1 = c ^ a; //ok var r9c2 = c ^ b; var r9c3 = c ^ c; //ok var r9c4 = c ^ d; var r9c5 = c ^ e; var r9c6 = c ^ f; var r9d1 = d ^ a; var r9d2 = d ^ b; var r9d3 = d ^ c; var r9d4 = d ^ d; var r9d5 = d ^ e; var r9d6 = d ^ f; var r9e1 = e ^ a; var r9e2 = e ^ b; var r9e3 = e ^ c; var r9e4 = e ^ d; var r9e5 = e ^ e; var r9e6 = e ^ f; var r9f1 = f ^ a; var r9f2 = f ^ b; var r9f3 = f ^ c; var r9f4 = f ^ d; var r9f5 = f ^ e; var r9f6 = f ^ f; var r9g1 = E.a ^ a; //ok var r9g2 = E.a ^ b; var r9g3 = E.a ^ c; //ok var r9g4 = E.a ^ d; var r9g5 = E.a ^ e; var r9g6 = E.a ^ f; var r9h1 = a ^ E.b; //ok var r9h2 = b ^ E.b; var r9h3 = c ^ E.b; //ok var r9h4 = d ^ E.b; var r9h5 = e ^ E.b; var r9h6 = f ^ E.b; // operator | var r10a1 = a | a; //ok var r10a2 = a | b; var r10a3 = a | c; //ok var r10a4 = a | d; var r10a5 = a | e; var r10a6 = a | f; var r10b1 = b | a; var r10b2 = b | b; var r10b3 = b | c; var r10b4 = b | d; var r10b5 = b | e; var r10b6 = b | f; var r10c1 = c | a; //ok var r10c2 = c | b; var r10c3 = c | c; //ok var r10c4 = c | d; var r10c5 = c | e; var r10c6 = c | f; var r10d1 = d | a; var r10d2 = d | b; var r10d3 = d | c; var r10d4 = d | d; var r10d5 = d | e; var r10d6 = d | f; var r10e1 = e | a; var r10e2 = e | b; var r10e3 = e | c; var r10e4 = e | d; var r10e5 = e | e; var r10e6 = e | f; var r10f1 = f | a; var r10f2 = f | b; var r10f3 = f | c; var r10f4 = f | d; var r10f5 = f | e; var r10f6 = f | f; var r10g1 = E.a | a; //ok var r10g2 = E.a | b; var r10g3 = E.a | c; //ok var r10g4 = E.a | d; var r10g5 = E.a | e; var r10g6 = E.a | f; var r10h1 = a | E.b; //ok var r10h2 = b | E.b; var r10h3 = c | E.b; //ok var r10h4 = d | E.b; var r10h5 = e | E.b; var r10h6 = f | E.b;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arithmeticOperatorWithTypeParameter.ts
TypeScript
// type parameter type is not valid for arithmetic operand function foo<T>(t: T) { var a: any; var b: boolean; var c: number; var d: string; var e: {}; var r1a1 = a * t; var r1a2 = a / t; var r1a3 = a % t; var r1a4 = a - t; var r1a5 = a << t; var r1a6 = a >> t; var r1a7 = a >>> t; var r1a8 = a & t; var r1a9 = a ^ t; var r1a10 = a | t; var r2a1 = t * a; var r2a2 = t / a; var r2a3 = t % a; var r2a4 = t - a; var r2a5 = t << a; var r2a6 = t >> a; var r2a7 = t >>> a; var r2a8 = t & a; var r2a9 = t ^ a; var r2a10 = t | a; var r1b1 = b * t; var r1b2 = b / t; var r1b3 = b % t; var r1b4 = b - t; var r1b5 = b << t; var r1b6 = b >> t; var r1b7 = b >>> t; var r1b8 = b & t; var r1b9 = b ^ t; var r1b10 = b | t; var r2b1 = t * b; var r2b2 = t / b; var r2b3 = t % b; var r2b4 = t - b; var r2b5 = t << b; var r2b6 = t >> b; var r2b7 = t >>> b; var r2b8 = t & b; var r2b9 = t ^ b; var r2b10 = t | b; var r1c1 = c * t; var r1c2 = c / t; var r1c3 = c % t; var r1c4 = c - t; var r1c5 = c << t; var r1c6 = c >> t; var r1c7 = c >>> t; var r1c8 = c & t; var r1c9 = c ^ t; var r1c10 = c | t; var r2c1 = t * c; var r2c2 = t / c; var r2c3 = t % c; var r2c4 = t - c; var r2c5 = t << c; var r2c6 = t >> c; var r2c7 = t >>> c; var r2c8 = t & c; var r2c9 = t ^ c; var r2c10 = t | c; var r1d1 = d * t; var r1d2 = d / t; var r1d3 = d % t; var r1d4 = d - t; var r1d5 = d << t; var r1d6 = d >> t; var r1d7 = d >>> t; var r1d8 = d & t; var r1d9 = d ^ t; var r1d10 = d | t; var r2d1 = t * d; var r2d2 = t / d; var r2d3 = t % d; var r2d4 = t - d; var r2d5 = t << d; var r2d6 = t >> d; var r2d7 = t >>> d; var r2d8 = t & d; var r2d9 = t ^ d; var r2d10 = t | d; var r1e1 = e * t; var r1e2 = e / t; var r1e3 = e % t; var r1e4 = e - t; var r1e5 = e << t; var r1e6 = e >> t; var r1e7 = e >>> t; var r1e8 = e & t; var r1e9 = e ^ t; var r1e10 = e | t; var r2e1 = t * e; var r2e2 = t / e; var r2e3 = t % e; var r2e4 = t - e; var r2e5 = t << e; var r2e6 = t >> e; var r2e7 = t >>> e; var r2e8 = t & e; var r2e9 = t ^ e; var r2e10 = t | e; var r1f1 = t * t; var r1f2 = t / t; var r1f3 = t % t; var r1f4 = t - t; var r1f5 = t << t; var r1f6 = t >> t; var r1f7 = t >>> t; var r1f8 = t & t; var r1f9 = t ^ t; var r1f10 = t | t; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arityAndOrderCompatibility01.ts
TypeScript
interface StrNum extends Array<string|number> { 0: string; 1: number; length: 2; } var x: [string, number]; var y: StrNum var z: { 0: string; 1: number; length: 2; } var [a, b, c] = x; var [d, e, f] = y; var [g, h, i] = z; var j1: [number, number, number] = x; var j2: [number, number, number] = y; var j3: [number, number, number] = z; var k1: [string, number, number] = x; var k2: [string, number, number] = y; var k3: [string, number, number] = z; var l1: [number] = x; var l2: [number] = y; var l3: [number] = z; var m1: [string] = x; var m2: [string] = y; var m3: [string] = z; var n1: [number, string] = x; var n2: [number, string] = y; var n3: [number, string] = z; var o1: [string, number] = x; var o2: [string, number] = y; var o3: [string, number] = y;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayAssignmentPatternWithAny.ts
TypeScript
var a: any; var x: string; [x] = a;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayLiteral.ts
TypeScript
// valid uses of array literals var x = []; var x = new Array(1); var y = [1]; var y = [1, 2]; var y = new Array<number>(); var x2: number[] = []; var x2: number[] = new Array(1); var y2: number[] = [1]; var y2: number[] = [1, 2]; var y2: number[] = new Array<number>();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayLiteralExpressionContextualTyping.ts
TypeScript
// In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by // the type of the property with the numeric name N in the contextual type, if any, or otherwise // the numeric index type of the contextual type, if any. var array = [1, 2, 3]; var array1 = [true, 2, 3]; // Contextual type by the numeric index type of the contextual type var tup: [number, number, number] = [1, 2, 3, 4]; var tup1: [number|string, number|string, number|string] = [1, 2, 3, "string"]; var tup2: [number, number, number] = [1, 2, 3, "string"]; // Error // In a contextually typed array literal expression containing one or more spread elements, // an element expression at index N is contextually typed by the numeric index type of the contextual type, if any. var spr = [1, 2, 3, ...array]; var spr1 = [1, 2, 3, ...tup]; var spr2:[number, number, number] = [1, 2, 3, ...tup]; // Error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayLiteralInference.ts
TypeScript
// @strict: true // @target: es2015 // Repro from #31204 export enum AppType { HeaderDetail = 'HeaderDetail', HeaderMultiDetail = 'HeaderMultiDetail', AdvancedList = 'AdvancedList', Standard = 'Standard', Relationship = 'Relationship', Report = 'Report', Composite = 'Composite', ListOnly = 'ListOnly', ModuleSettings = 'ModuleSettings' } export enum AppStyle { Tree, TreeEntity, Standard, MiniApp, PivotTable } const appTypeStylesWithError: Map<AppType, Array<AppStyle>> = new Map([ [AppType.Standard, [AppStyle.Standard, AppStyle.MiniApp]], [AppType.Relationship, [AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity]], [AppType.AdvancedList, [AppStyle.Standard, AppStyle.MiniApp]] ]); // Repro from #31204 declare function foo<T>(...args: T[]): T[]; let b1: { x: boolean }[] = foo({ x: true }, { x: false }); let b2: boolean[][] = foo([true], [false]);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayLiteralSpread.ts
TypeScript
function f0() { var a = [1, 2, 3]; var a1 = [...a]; var a2 = [1, ...a]; var a3 = [1, 2, ...a]; var a4 = [...a, 1]; var a5 = [...a, 1, 2]; var a6 = [1, 2, ...a, 1, 2]; var a7 = [1, ...a, 2, ...a]; var a8 = [...a, ...a, ...a]; } function f1() { var a = [1, 2, 3]; var b = ["hello", ...a, true]; var b: (string | number | boolean)[]; } function f2() { var a = [...[...[...[...[...[]]]]]]; var b = [...[...[...[...[...[5]]]]]]; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayLiteralSpreadES5iterable.ts
TypeScript
// @downlevelIteration: true function f0() { var a = [1, 2, 3]; var a1 = [...a]; var a2 = [1, ...a]; var a3 = [1, 2, ...a]; var a4 = [...a, 1]; var a5 = [...a, 1, 2]; var a6 = [1, 2, ...a, 1, 2]; var a7 = [1, ...a, 2, ...a]; var a8 = [...a, ...a, ...a]; } function f1() { var a = [1, 2, 3]; var b = ["hello", ...a, true]; var b: (string | number | boolean)[]; } function f2() { var a = [...[...[...[...[...[]]]]]]; var b = [...[...[...[...[...[5]]]]]]; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayLiteralWidened.ts
TypeScript
// array literals are widened upon assignment according to their element type var a = []; // any[] var a = [,,]; var a = [null, null]; var a = [undefined, undefined]; var b = [[], [null, null]]; // any[][] var b = [[], []]; var b = [[undefined, undefined]]; var c = [[[]]]; // any[][][] var c = [[[null]],[undefined]] // no widening when one or more elements are non-widening var x: undefined = undefined; var d = [x]; var d = [, x]; var d = [undefined, x];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayLiteralWithMultipleBestCommonTypes.ts
TypeScript
// when multiple best common types exist we will choose the first candidate var a: { x: number; y?: number }; var b: { x: number; z?: number }; var c: { x: number; a?: number }; var as = [a, b]; // { x: number; y?: number };[] var bs = [b, a]; // { x: number; z?: number };[] var cs = [a, b, c]; // { x: number; y?: number };[] var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[] var fs = [(a: { x: number; y?: number }) => 1, (b: { x: number; z?: number }) => 2]; // (a: { x: number; y?: number }) => number[] var gs = [(b: { x: number; z?: number }) => 2, (a: { x: number; y?: number }) => 1]; // (b: { x: number; z?: number }) => number[]
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayLiterals.ts
TypeScript
// Empty array literal with no contextual type has type Undefined[] var arr1= [[], [1], ['']]; var arr2 = [[null], [1], ['']]; // Array literal with elements of only EveryType E has type E[] var stringArrArr = [[''], [""]]; var stringArr = ['', ""]; var numberArr = [0, 0.0, 0x00, 1e1]; var boolArr = [false, true, false, true]; class C { private p; } var classArr = [new C(), new C()]; var classTypeArray = [C, C, C]; var classTypeArray: Array<typeof C>; // Should OK, not be a parse error // Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; // Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[] class Base { private p; } class Derived1 extends Base { private m }; class Derived2 extends Base { private n }; var context3: Base[] = [new Derived1(), new Derived2()]; // Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[] var context4: Base[] = [new Derived1(), new Derived1()];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayLiterals2ES5.ts
TypeScript
// ElementList: ( Modified ) // Elisionopt AssignmentExpression // Elisionopt SpreadElement // ElementList, Elisionopt AssignmentExpression // ElementList, Elisionopt SpreadElement // SpreadElement: // ... AssignmentExpression var a0 = [,, 2, 3, 4] var a1 = ["hello", "world"] var a2 = [, , , ...a0, "hello"]; var a3 = [,, ...a0] var a4 = [() => 1, ]; var a5 = [...a0, , ] // Each element expression in a non-empty array literal is processed as follows: // - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) // by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, // the element expression is contextually typed by the type of that property. // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is contextually typed by a tuple-like type, // the resulting type is a tuple type constructed from the types of the element expressions. var b0: [any, any, any] = [undefined, null, undefined]; var b1: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), // the resulting type is a tuple type constructed from the types of the element expressions. var [c0, c1] = [1, 2]; // tuple type [number, number] var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] // The resulting type an array literal expression is determined as follows: // - the resulting type is an array type with an element type that is the union of the types of the // non - spread element expressions and the numeric index signature types of the spread element expressions var temp = ["s", "t", "r"]; var temp1 = [1, 2, 3]; var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; var temp3 = [undefined, null, undefined]; var temp4 = []; interface myArray extends Array<Number> { } interface myArray2 extends Array<Number|String> { } var d0 = [1, true, ...temp,]; // has type (string|number|boolean)[] var d1 = [...temp]; // has type string[] var d2: number[] = [...temp1]; var d3: myArray = [...temp1]; var d4: myArray2 = [...temp, ...temp1]; var d5 = [...temp3]; var d6 = [...temp4]; var d7 = [...[...temp1]]; var d8: number[][] = [[...temp1]] var d9 = [[...temp1], ...["hello"]];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayLiterals2ES6.ts
TypeScript
// @target:es6 // ElementList: ( Modified ) // Elisionopt AssignmentExpression // Elisionopt SpreadElement // ElementList, Elisionopt AssignmentExpression // ElementList, Elisionopt SpreadElement // SpreadElement: // ... AssignmentExpression var a0 = [, , 2, 3, 4] var a1 = ["hello", "world"] var a2 = [, , , ...a0, "hello"]; var a3 = [, , ...a0] var a4 = [() => 1, ]; var a5 = [...a0, , ] // Each element expression in a non-empty array literal is processed as follows: // - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) // by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, // the element expression is contextually typed by the type of that property. // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is contextually typed by a tuple-like type, // the resulting type is a tuple type constructed from the types of the element expressions. var b0: [any, any, any] = [undefined, null, undefined]; var b1: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), // the resulting type is a tuple type constructed from the types of the element expressions. var [c0, c1] = [1, 2]; // tuple type [number, number] var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] // The resulting type an array literal expression is determined as follows: // - the resulting type is an array type with an element type that is the union of the types of the // non - spread element expressions and the numeric index signature types of the spread element expressions var temp = ["s", "t", "r"]; var temp1 = [1, 2, 3]; var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; interface myArray extends Array<Number> { } interface myArray2 extends Array<Number|String> { } var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] var d1 = [...temp]; // has type string[] var d2: number[] = [...temp1]; var d3: myArray = [...temp1]; var d4: myArray2 = [...temp, ...temp1]; var d5 = [...a2]; var d6 = [...a3]; var d7 = [...a4]; var d8: number[][] = [[...temp1]] var d9 = [[...temp1], ...["hello"]];
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayLiterals3.ts
TypeScript
// Each element expression in a non-empty array literal is processed as follows: // - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) // by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, // the element expression is contextually typed by the type of that property. // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is contextually typed by a tuple-like type, // the resulting type is a tuple type constructed from the types of the element expressions. var a0: [any, any, any] = []; // Error var a1: [boolean, string, number] = ["string", 1, true]; // Error // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), // the resulting type is a tuple type constructed from the types of the element expressions. var [b1, b2]: [number, number] = [1, 2, "string", true]; // The resulting type an array literal expression is determined as follows: // - the resulting type is an array type with an element type that is the union of the types of the // non - spread element expressions and the numeric index signature types of the spread element expressions var temp = ["s", "t", "r"]; var temp1 = [1, 2, 3]; var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; interface tup { 0: number[]|string[]; 1: number[]|string[]; } interface myArray extends Array<Number> { } interface myArray2 extends Array<Number|String> { } var c0: tup = [...temp2]; // Error var c1: [number, number, number] = [...temp1]; // Error cannot assign number[] to [number, number, number] var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[]
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayLiteralsWithRecursiveGenerics.ts
TypeScript
class List<T> { data: T; next: List<List<T>>; } class DerivedList<U> extends List<U> { foo: U; // next: List<List<U>> } class MyList<T> { data: T; next: MyList<MyList<T>>; } var list: List<number>; var list2: List<string>; var myList: MyList<number>; var xs = [list, myList]; // {}[] var ys = [list, list2]; // {}[] var zs = [list, null]; // List<number>[] var myDerivedList: DerivedList<number>; var as = [list, myDerivedList]; // List<number>[]
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayOfFunctionTypes3.ts
TypeScript
// valid uses of arrays of function types var x = [() => 1, () => { }]; var r2 = x[0](); class C { foo: string; } var y = [C, C]; var r3 = new y[0](); var a: { (x: number): number; (x: string): string; }; var b: { (x: number): number; (x: string): string; }; var c: { (x: number): number; (x: any): any; }; var z = [a, b, c]; var r4 = z[0]; var r5 = r4(''); // any not string var r5b = r4(1); var a2: { <T>(x: T): number; (x: string): string;}; var b2: { <T>(x: T): number; (x: string): string; }; var c2: { (x: number): number; <T>(x: T): any; }; var z2 = [a2, b2, c2]; var r6 = z2[0]; var r7 = r6(''); // any not string
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arraySpreadImportHelpers.ts
TypeScript
// @target: es5 // @importHelpers: true // @isolatedModules: true // @noTypesAndSymbols: true // @noEmit: true // @filename: main.ts export {}; const k = [1, , 2]; const o = [3, ...k, 4]; // @filename: tslib.d.ts // this is a pre-TS4.4 versions of emit helper, which always forced array packing declare module "tslib" { function __spreadArray(to: any[], from: any[]): any[]; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arraySpreadInCall.ts
TypeScript
// @strict: true // @noEmit: true declare function f1(a: number, b: number, c: number, d: number, e: number, f: number): void; f1(1, 2, 3, 4, ...[5, 6]); f1(...[1], 2, 3, 4, 5, 6); f1(1, 2, ...[3, 4], 5, 6); f1(1, 2, ...[3], 4, ...[5, 6]); f1(...[1, 2], ...[3, 4], ...[5, 6]); f1(...(([1, 2])), ...(((([3, 4])))), ...([5, 6])); declare function f2<T extends unknown[]>(...args: T): T; const x21 = f2(...[1, 'foo']) const x22 = f2(true, ...[1, 'foo']) const x23 = f2(...([1, 'foo'])) const x24 = f2(true, ...([1, 'foo'])) declare function f3<T extends readonly unknown[]>(...args: T): T; const x31 = f3(...[1, 'foo']) const x32 = f3(true, ...[1, 'foo']) const x33 = f3(...([1, 'foo'])) const x34 = f3(true, ...([1, 'foo'])) declare function f4<const T extends readonly unknown[]>(...args: T): T; const x41 = f4(...[1, 'foo']) const x42 = f4(true, ...[1, 'foo']) const x43 = f4(...([1, 'foo'])) const x44 = f4(true, ...([1, 'foo'])) // dicovered in #52845#issuecomment-1459132562 interface IAction { run(event?: unknown): unknown; } declare const action: IAction action.run(...[100, 'foo']) // error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayTypeOfFunctionTypes.ts
TypeScript
// valid uses of arrays of function types var x: () => string[]; var r = x[1]; var r2 = r(); var r2b = new r(); var x2: { (): string }[]; var r3 = x2[1]; var r4 = r3(); var r4b = new r3(); // error var x3: Array<() => string>; var r5 = x2[1]; var r6 = r5(); var r6b = new r5(); // error
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayTypeOfFunctionTypes2.ts
TypeScript
// valid uses of arrays of function types var x: new () => string[]; var r = x[1]; var r2 = new r(); var r2b = r(); var x2: { new(): string }[]; var r3 = x[1]; var r4 = new r3(); var r4b = new r3(); var x3: Array<new () => string>; var r5 = x2[1]; var r6 = new r5(); var r6b = r5();
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrayTypeOfTypeOf.ts
TypeScript
// array type cannot use typeof. var x = 1; var xs: typeof x[]; // Not an error. This is equivalent to Array<typeof x> var xs2: typeof Array; var xs3: typeof Array<number>; var xs4: typeof Array<typeof x>;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrowFunctionExpressions.ts
TypeScript
// ArrowFormalParameters => AssignmentExpression is equivalent to ArrowFormalParameters => { return AssignmentExpression; } var a = (p: string) => p.length; var a = (p: string) => { return p.length; } // Identifier => Block is equivalent to(Identifier) => Block var b = j => { return 0; } var b = (j) => { return 0; } // Identifier => AssignmentExpression is equivalent to(Identifier) => AssignmentExpression var c: number; var d = n => c = n; var d = (n) => c = n; var d: (n: any) => any; // Binding patterns in arrow functions var p1 = ([a]) => { }; var p2 = ([...a]) => { }; var p3 = ([, a]) => { }; var p4 = ([, ...a]) => { }; var p5 = ([a = 1]) => { }; var p6 = ({ a }) => { }; var p7 = ({ a: { b } }) => { }; var p8 = ({ a = 1 }) => { }; var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; var p10 = ([{ value, done }]) => { }; // Arrow function used in class member initializer // Arrow function used in class member function class MyClass { m = (n) => n + 1; p = (n) => n && this; fn() { var m = (n) => n + 1; var p = (n) => n && this; } } // Arrow function used in arrow function var arrrr = () => (m: number) => () => (n: number) => m + n; var e = arrrr()(3)()(4); var e: number; // Arrow function used in arrow function used in function function someFn() { var arr = (n: number) => (p: number) => p * n; arr(3)(4).toExponential(); } // Arrow function used in function function someOtherFn() { var arr = (n: number) => '' + n; arr(4).charAt(0); } // Arrow function used in nested function in function function outerFn() { function innerFn() { var arrowFn = () => { }; var p = arrowFn(); var p: void; } } // Arrow function used in nested function in arrow function var f = (n: string) => { function fn(x: number) { return () => n + x; } return fn(4); } var g = f('')(); var g: string; // Arrow function used in nested function in arrow function in nested function function someOuterFn() { var arr = (n: string) => { function innerFn() { return () => n.length; } return innerFn; } return arr; } var h = someOuterFn()('')()(); h.toExponential(); // Arrow function used in try/catch/finally in function function tryCatchFn() { try { var x = () => this; } catch (e) { var t = () => e + this; } finally { var m = () => this + ''; } }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrowFunctionWithParameterNameAsync_es2017.ts
TypeScript
// @target: ES5 // @noEmitHelpers: true const x = async => async;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrowFunctionWithParameterNameAsync_es5.ts
TypeScript
// @target: ES5 // @lib: es5,es2015.promise // @noEmitHelpers: true const x = async => async;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/arrowFunctionWithParameterNameAsync_es6.ts
TypeScript
// @target: ES5 // @noEmitHelpers: true const x = async => async;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asOpEmitParens.ts
TypeScript
declare var x; // Must emit as (x + 1) * 3 (x + 1 as number) * 3; // Should still emit as x.y (x as any).y; // Emit as new (x()) new (x() as any);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asOperator1.ts
TypeScript
var as = 43; var x = undefined as number; var y = (null as string).length; var z = Date as any as string; // Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' var j = 32 as number|string; j = '';
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asOperator2.ts
TypeScript
var x = 23 as string;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asOperator3.ts
TypeScript
declare function tag(...x: any[]): any; var a = `${123 + 456 as number}`; var b = `leading ${123 + 456 as number}`; var c = `${123 + 456 as number} trailing`; var d = `Hello ${123} World` as string; var e = `Hello` as string; var f = 1 + `${1} end of string` as string; var g = tag `Hello ${123} World` as string; var h = tag `Hello` as string;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asOperator4.ts
TypeScript
//@module: commonjs //@filename: foo.ts export function foo() { } //@filename: bar.ts import { foo } from './foo'; // These should emit identically <any>foo; (foo as any);
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asOperatorASI.ts
TypeScript
class Foo { } declare function as(...args: any[]); // Example 1 var x = 10 as `Hello world`; // should not error // Example 2 var y = 20 as(Foo); // should emit
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asOperatorAmbiguity.ts
TypeScript
interface A<T> { x: T; } interface B { m: string; } // Make sure this is a type assertion to an array type, and not nested comparison operators. var x: any; var y = x as A<B>[]; var z = y[0].m; // z should be string
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asOperatorContextualType.ts
TypeScript
// should error var x = (v => v) as (x: number) => string;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asOperatorNames.ts
TypeScript
var a = 20; var b = a as string; var as = "hello"; var as1 = as as string;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asiPreventsParsingAsAmbientExternalModule01.ts
TypeScript
var declare: number; var module: string; declare // this is the identifier 'declare' module // this is the identifier 'module' "my external module" // this is just a string { } // this is a block body
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asiPreventsParsingAsAmbientExternalModule02.ts
TypeScript
var declare: number; var module: string; module container { declare // this is the identifier 'declare' module // this is the identifier 'module' "my external module" // this is just a string { } // this is a block body }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asiPreventsParsingAsInterface01.ts
TypeScript
var interface: number, I: string; interface // This should be the identifier 'interface' I // This should be the identifier 'I' {} // This should be a block body
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asiPreventsParsingAsInterface02.ts
TypeScript
function f(interface: number, I: string) { interface // This should be the identifier 'interface' I // This should be the identifier 'I' {} // This should be a block body }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asiPreventsParsingAsInterface03.ts
TypeScript
var interface: number, I: string; namespace n { interface // This should be the identifier 'interface' I // This should be the identifier 'I' {} // This should be a block body }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asiPreventsParsingAsInterface04.ts
TypeScript
var declare: boolean, interface: number, I: string; declare // This should be the identifier 'declare' interface // This should be the identifier 'interface' I // This should be the identifier 'I' {} // This should be a block body
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asiPreventsParsingAsNamespace01.ts
TypeScript
var namespace: number; var n: string; namespace // this is the identifier 'namespace' n // this is the identifier 'n' { } // this is a block body
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asiPreventsParsingAsNamespace02.ts
TypeScript
var module: number; var m: string; module // this is the identifier 'namespace' m // this is the identifier 'm' { } // this is a block body
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asiPreventsParsingAsNamespace03.ts
TypeScript
var namespace: number; var n: string; namespace container { namespace // this is the identifier 'namespace' n // this is the identifier 'n' { } // this is a block body }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asiPreventsParsingAsNamespace04.ts
TypeScript
let module = 10; module in {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asiPreventsParsingAsNamespace05.ts
TypeScript
let namespace = 10; namespace a.b { export let c = 20; } namespace a.b.c { }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_ecma_parser/tests/tsc/asiPreventsParsingAsTypeAlias01.ts
TypeScript
var type; var string; var Foo; type Foo = string;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University