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/esDecoratorsMetadata5.ts | TypeScript | // @target: es2022
// @noTypesAndSymbols: true
// @filename: /foo.ts
declare var metadata: any;
class C {
@metadata m() {}
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekind.ts | TypeScript | // @target: ES6
// @sourcemap: false
// @declaration: false
// @module: esnext
export default class A
{
constructor ()
{
}
public B()
{
return 42;
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES2015Target.ts | TypeScript | // @target: es2015
// @sourcemap: false
// @declaration: false
// @module: es6
export default class A
{
constructor ()
{
}
public B()
{
return 42;
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target.ts | TypeScript | // @target: es5
// @module: esnext
// @experimentalDecorators: true
export class C {
static s = 0;
p = 1;
method() { }
}
export { C as C2 };
declare function foo(...args: any[]): any;
@foo
export class D {
static s = 0;
p = 1;
method() { }
}
export { D as D2 };
class E { }
export {E};
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target10.ts | TypeScript | // @target: es5
// @module: esnext
import i = require("mod"); // Error;
namespace N {
}
export = N; // Error | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target11.ts | TypeScript | // @target: es5
// @module: esnext
// @experimentalDecorators: true
declare function foo(...args: any[]): any;
@foo
export default class C {
static x() { return C.y; }
static y = 1
p = 1;
method() { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target12.ts | TypeScript | // @target: es5
// @module: esnext
export class C {
}
export namespace C {
export const x = 1;
}
export enum E {
w = 1
}
export enum E {
x = 2
}
export namespace E {
export const y = 1;
}
export namespace E {
export const z = 1;
}
export namespace N {
}
export namespace N {
export const x = 1;
}
export function F() {
}
export namespace F {
export const x = 1;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target2.ts | TypeScript | // @target: es5
// @module: esnext
export default class C {
static s = 0;
p = 1;
method() { }
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target3.ts | TypeScript | // @target: es5
// @module: esnext
// @experimentalDecorators: true
declare function foo(...args: any[]): any;
@foo
export default class D {
static s = 0;
p = 1;
method() { }
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target4.ts | TypeScript | // @target: es5
// @module: esnext
class E { }
export default E; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target5.ts | TypeScript | // @target: es5
// @module: esnext
// @preserveConstEnums: true
export enum E1 {
value1
}
export const enum E2 {
value1
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target6.ts | TypeScript | // @target: es5
// @module: esnext
export function f1(d = 0) {
}
export function f2(...arg) {
}
export default function f3(d = 0) {
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target7.ts | TypeScript | // @target: es5
// @module: esnext
export namespace N {
var x = 0;
}
export namespace N2 {
export interface I { }
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target8.ts | TypeScript | // @target: es5
// @module: esnext
export const c = 0;
export let l = 1; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target9.ts | TypeScript | // @target: es5
// @module: esnext
import d from "mod";
import {a} from "mod";
import * as M from "mod";
export {a};
export {M};
export {d};
export * from "mod";
export {b} from "mod"
export default d;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/everyTypeAssignableToAny.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;
var c: string;
var d: boolean;
var e: Date;
var f: any;
var g: void;
var h: Object;
var i: {};
var j: () => {};
var k: Function;
var l: (x: number) => string;
var m: number[];
var n: { foo: string };
var o: <T>(x: T) => T;
var p: Number;
var q: String;
a = b;
a = c;
a = d;
a = e;
a = f;
a = g;
a = h;
a = i;
a = j;
a = k;
a = l;
a = m;
a = o;
a = p;
a = q;
a = ac;
a = ai;
a = ae;
function foo<T, U /*extends T*/, V extends Date>(x: T, y: U, z: V) {
a = x;
a = y;
a = z;
}
//function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) {
// a = x;
// a = y;
// a = z;
//} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/everyTypeWithAnnotationAndInitializer.ts | TypeScript | 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(); }
}
var aNumber: number = 9.9;
var aString: string = 'this is a string';
var aDate: Date = new Date(12);
var anObject: Object = new Object();
var anAny: any = null;
var aSecondAny: any = undefined;
var aVoid: void = undefined;
var anInterface: I = new C();
var aClass: C = new C();
var aGenericClass: D<string> = new D<string>();
var anObjectLiteral: I = { id: 12 };
var anOtherObjectLiteral: { id: number } = new C();
var aFunction: typeof F = F;
var anOtherFunction: (x: string) => number = F;
var aLambda: typeof F = (x) => 2;
var aModule: typeof M = M;
var aClassInModule: M.A = new M.A();
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/everyTypeWithAnnotationAndInvalidInitializer.ts | TypeScript | 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; }
function F2(x: number): boolean { return x < 42; }
module M {
export class A {
name: string;
}
export function F2(x: number): string { return x.toString(); }
}
module N {
export class A {
id: number;
}
export function F2(x: number): string { return x.toString(); }
}
var aNumber: number = 'this is a string';
var aString: string = 9.9;
var aDate: Date = 9.9;
var aVoid: void = 9.9;
var anInterface: I = new D();
var aClass: C = new D();
var aGenericClass: D<string> = new C();
var anObjectLiteral: I = { id: 'a string' };
var anOtherObjectLiteral: { id: string } = new C();
var aFunction: typeof F = F2;
var anOtherFunction: (x: string) => number = F2;
var aLambda: typeof F = (x) => 'a string';
var aModule: typeof M = N;
var aClassInModule: M.A = new N.A();
var aFunctionInModule: typeof M.F2 = F2;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/everyTypeWithInitializer.ts | TypeScript | 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(); }
}
var aNumber = 9.9;
var aString = 'this is a string';
var aDate = new Date(12);
var anObject = new Object();
var anAny = null;
var anOtherAny = <any> new C();
var anUndefined = undefined;
var aClass = new C();
var aGenericClass = new D<string>();
var anObjectLiteral = { id: 12 };
var aFunction = F;
var aLambda = (x) => 2;
var aModule = M;
var aClassInModule = new M.A();
var aFunctionInModule = M.F2;
// no initializer or annotation, so this is an 'any'
var x;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exhaustiveSwitchStatements1.ts | TypeScript | // @strict: true
// @allowUnreachableCode: false
// @declaration: true
function f1(x: 1 | 2): string {
if (!!true) {
switch (x) {
case 1: return 'a';
case 2: return 'b';
}
x; // Unreachable
}
else {
throw 0;
}
}
function f2(x: 1 | 2) {
let z: number;
switch (x) {
case 1: z = 10; break;
case 2: z = 20; break;
}
z; // Definitely assigned
}
function f3(x: 1 | 2) {
switch (x) {
case 1: return 10;
case 2: return 20;
// Default considered reachable to allow defensive coding
default: throw new Error("Bad input");
}
}
// Repro from #11572
enum E { A, B }
function f(e: E): number {
switch (e) {
case E.A: return 0
case E.B: return 1
}
}
function g(e: E): number {
if (!true)
return -1
else
switch (e) {
case E.A: return 0
case E.B: return 1
}
}
// Repro from #12668
interface Square { kind: "square"; size: number; }
interface Rectangle { kind: "rectangle"; width: number; height: number; }
interface Circle { kind: "circle"; radius: number; }
interface Triangle { kind: "triangle"; side: number; }
type Shape = Square | Rectangle | Circle | Triangle;
function area(s: Shape): number {
let area;
switch (s.kind) {
case "square": area = s.size * s.size; break;
case "rectangle": area = s.width * s.height; break;
case "circle": area = Math.PI * s.radius * s.radius; break;
case "triangle": area = Math.sqrt(3) / 4 * s.side * s.side; break;
}
return area;
}
function areaWrapped(s: Shape): number {
let area;
area = (() => {
switch (s.kind) {
case "square": return s.size * s.size;
case "rectangle": return s.width * s.height;
case "circle": return Math.PI * s.radius * s.radius;
case "triangle": return Math.sqrt(3) / 4 * s.side * s.side;
}
})();
return area;
}
// Repro from #13241
enum MyEnum {
A,
B
}
function thisGivesError(e: MyEnum): string {
let s: string;
switch (e) {
case MyEnum.A: s = "it was A"; break;
case MyEnum.B: s = "it was B"; break;
}
return s;
}
function good1(e: MyEnum): string {
let s: string;
switch (e) {
case MyEnum.A: s = "it was A"; break;
case MyEnum.B: s = "it was B"; break;
default: s = "it was something else"; break;
}
return s;
}
function good2(e: MyEnum): string {
switch (e) {
case MyEnum.A: return "it was A";
case MyEnum.B: return "it was B";
}
}
// Repro from #18362
enum Level {
One,
Two,
}
const doSomethingWithLevel = (level: Level) => {
let next: Level;
switch (level) {
case Level.One:
next = Level.Two;
break;
case Level.Two:
next = Level.One;
break;
}
return next;
};
// Repro from #20409
interface Square2 {
kind: "square";
size: number;
}
interface Circle2 {
kind: "circle";
radius: number;
}
type Shape2 = Square2 | Circle2;
function withDefault(s1: Shape2, s2: Shape2): string {
switch (s1.kind) {
case "square":
return "1";
case "circle":
switch (s2.kind) {
case "square":
return "2";
case "circle":
return "3";
default:
return "never";
}
}
}
function withoutDefault(s1: Shape2, s2: Shape2): string {
switch (s1.kind) {
case "square":
return "1";
case "circle":
switch (s2.kind) {
case "square":
return "2";
case "circle":
return "3";
}
}
}
// Repro from #20823
function test4(value: 1 | 2) {
let x: string;
switch (value) {
case 1: x = "one"; break;
case 2: x = "two"; break;
}
return x;
}
// Repro from #34661
enum Animal { DOG, CAT }
declare const zoo: { animal: Animal } | undefined;
function expression(): Animal {
switch (zoo?.animal ?? Animal.DOG) {
case Animal.DOG: return Animal.DOG
case Animal.CAT: return Animal.CAT
}
}
// Repro from #34840
function foo() {
const foo: number | undefined = 0;
while (true) {
const stats = foo;
switch (stats) {
case 1: break;
case 2: break;
}
}
}
// Repro from #35070
type O = {
a: number,
b: number
};
type K = keyof O | 'c';
function ff(o: O, k: K) {
switch(k) {
case 'c':
k = 'a';
}
k === 'c'; // Error
return o[k];
}
// Repro from #35431
type A = { kind: "abc" } | { kind: "def" };
function f35431(a: A) {
switch (a.kind) {
case "abc":
case "def": return;
default:
a!.kind; // Error expected
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exnextmodulekindExportClassNameWithObject.ts | TypeScript | // @target: ES5
// @module: esnext
export class Object {}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/expandoOnAlias.ts | TypeScript | // @allowJs: true
// @checkJs: true
// @declaration: true
// @emitDeclarationOnly: true
// @Filename: vue.js
export class Vue {}
export const config = { x: 0 };
// @Filename: test.js
import { Vue, config } from "./vue";
// Expando declarations aren't allowed on aliases.
Vue.config = {};
new Vue();
// This is not an expando declaration; it's just a plain property assignment.
config.x = 1;
// This is not an expando declaration; it works because non-strict JS allows
// loosey goosey assignment on objects.
config.y = {};
config.x;
config.y;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exponentiationOperatorWithAnyAndNumber.ts | TypeScript | var a: any;
var b: number;
// operator **
var r1 = a ** a;
var r2 = a ** b;
var r3 = a ** 0;
var r4 = 0 ** a;
var r5 = 0 ** 0;
var r6 = b ** 0;
var r7 = 0 ** b;
var r8 = b ** b; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exponentiationOperatorWithEnum.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 r1 = c ** a;
var r2 = c ** b;
var r3 = c ** c;
var r4 = a ** c;
var r5 = b ** c;
var r6 = E.a ** a;
var r7 = E.a ** b;
var r8 = E.a ** E.b;
var r9 = E.a ** 1;
var r10 = a ** E.b;
var r11 = b ** E.b;
var r12 = 1 ** E.b; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exponentiationOperatorWithEnumUnion.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 r1 = c ** a;
var r2 = c ** b;
var r3 = c ** c;
var r4 = a ** c;
var r5 = b ** c;
var r6 = E.a ** a;
var r7 = E.a ** b;
var r8 = E.a ** E.b;
var r9 = E.a ** 1;
var r10 = a ** E.b;
var r11 = b ** E.b;
var r12 = 1 ** E.b; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exponentiationOperatorWithInvalidOperands.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 | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exponentiationOperatorWithInvalidSimpleUnaryExpressionOperands.ts | TypeScript | var temp: any;
// Error: incorrect type on left-hand side
(! --temp) ** 3;
(!temp--) ** 3;
(!3) ** 4;
(!temp++) ** 4;
(!temp--) ** 4;
(! --temp) ** 3 ** 1;
(!temp--) ** 3 ** 1;
(!3) ** 4 ** 1;
(!temp++) ** 4 ** 1;
(!temp--) ** 4 ** 1;
(typeof --temp) ** 3;
(typeof temp--) ** 3;
(typeof 3) ** 4;
(typeof temp++) ** 4;
(typeof temp--) ** 4;
1 ** (typeof --temp) ** 3;
1 ** (typeof temp--) ** 3;
1 ** (typeof 3) ** 4;
1 ** (typeof temp++) ** 4;
1 ** (typeof temp--) ** 4;
(delete --temp) ** 3;
(delete ++temp) ** 3;
(delete temp--) ** 3;
(delete temp++) ** 3;
1 ** (delete --temp) ** 3;
1 ** (delete ++temp) ** 3;
1 ** (delete temp--) ** 3;
1 ** (delete temp++) ** 3; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exponentiationOperatorWithNew.ts | TypeScript | var a: any;
var b: any;
var c: any;
new a ** b ** c;
new a ** new b ** c;
new (a ** b ** c); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exponentiationOperatorWithTemplateStringInvalid.ts | TypeScript | // @target: es5
var a = 1 ** `${ 3 }`;
var b = 1 ** `2${ 3 }`;
var c = 1 ** `${ 3 }4`;
var d = 1 ** `2${ 3 }4`;
var e = `${ 3 }` ** 5;
var f = `2${ 3 }` ** 5;
var g = `${ 3 }4` ** 5;
var h = `2${ 3 }4` ** 5;
var k = 10;
k **= `${ 3 }`;
k **= `2${ 3 }`;
k **= `2${ 3 }4`;
k **= `2${ 3 }4`;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exponentiationOperatorWithTemplateStringInvalidES6.ts | TypeScript | // @target: es6
var a = 1 ** `${ 3 }`;
var b = 1 ** `2${ 3 }`;
var c = 1 ** `${ 3 }4`;
var d = 1 ** `2${ 3 }4`;
var e = `${ 3 }` ** 5;
var f = `2${ 3 }` ** 5;
var g = `${ 3 }4` ** 5;
var h = `2${ 3 }4` ** 5;
var k = 10;
k **= `${ 3 }`;
k **= `2${ 3 }`;
k **= `2${ 3 }4`;
kj **= `2${ 3 }4`; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exponentiationOperatorWithTypeParameter.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 r2a1 = t ** a;
var r1b1 = b ** t;
var r2b1 = t ** b;
var r1c1 = c ** t;
var r2c1 = t ** c;
var r1d1 = d ** t;
var r2d1 = t ** d;
var r1e1 = e ** t;
var r2e1 = t ** d;
var r1f1 = t ** t;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAmbientClassNameWithObject.ts | TypeScript | // @target: ES5
export declare class Object {}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAndImport-es5-amd.ts | TypeScript | //@module: amd
//@target: ES5
// @filename: m1.ts
export default function f1() {
}
// @filename: m2.ts
import f1 from "./m1";
export default function f2() {
f1();
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAndImport-es5.ts | TypeScript | //@module: commonjs
//@target: ES5
// @filename: m1.ts
export default function f1() {
}
// @filename: m2.ts
import f1 from "./m1";
export default function f2() {
f1();
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAsNamespace1.ts | TypeScript | // @module: esnext, es2015, commonjs, amd, system, umd
// @filename: 0.ts
// @declaration: true
export const a = 1;
export const b = 2;
// @filename: 1.ts
export * as ns from './0';
ns.a;
ns.b;
// @filename: 2.ts
import * as foo from './1'
foo.ns.a;
foo.ns.b; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAsNamespace2.ts | TypeScript | // @module: esnext, es2015, commonjs, amd, system, umd
// @filename: 0.ts
// @declaration: true
// @esModuleInterop: true
export const a = 1;
export const b = 2;
// @filename: 1.ts
export * as ns from './0';
ns.a;
ns.b;
// @filename: 2.ts
import * as foo from './1'
foo.ns.a;
foo.ns.b; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAsNamespace3.ts | TypeScript | // @module: esnext, es2015, commonjs, amd, system, umd
// @filename: 0.ts
// @declaration: true
// @esModuleInterop: true
export const a = 1;
export const b = 2;
// @filename: 1.ts
export * as ns from './0';
ns.a;
ns.b;
let ns = {a: 1, b: 2}
ns.a;
ns.b;
// @filename: 2.ts
import * as foo from './1'
foo.ns.a;
foo.ns.b; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAsNamespace4.ts | TypeScript | // @module: esnext, es2015, commonjs, amd, system, umd
// @filename: 0.ts
// @declaration: true
// @esModuleInterop: true
export const a = 1;
export const b = 2;
// @filename: 1.ts
export * as default from './0';
// @filename: 11.ts
import * as ns from './0';
export default ns;
// @filename: 2.ts
import foo from './1'
import foo1 from './11'
foo.a;
foo1.a;
foo.b;
foo1.b; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAsNamespace5.ts | TypeScript | // @module: esnext
// @moduleResolution: bundler
// @filename: three.d.ts
export type Named = 0;
declare const Named: 0;
// @filename: two.d.ts
export * as default from "./three";
// @filename: one.ts
import ns from "./two";
type Alias = ns.Named;
ns.Named;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAsNamespace_exportAssignment.ts | TypeScript | // @module: commonjs
// @esModuleInterop: true
// @noTypesAndSymbols: true
// @Filename: a.ts
export = {}
// @Filename: b.ts
export * as ns from './a';
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAsNamespace_missingEmitHelpers.ts | TypeScript | // @module: commonjs
// @importHelpers: true
// @esModuleInterop: true
// @noTypesAndSymbols: true
// @Filename: a.ts
export {}
// @Filename: b.ts
export * as ns from './a'; // Error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAsNamespace_nonExistent.ts | TypeScript | // @module: esnext
// @noTypesAndSymbols: true
export * as ns from './nonexistent'; // Error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignDottedName.ts | TypeScript | // @Filename: foo1.ts
export function x(){
return true;
}
// @Filename: foo2.ts
import foo1 = require('./foo1');
export = foo1.x; // Ok
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignImportedIdentifier.ts | TypeScript | // @Filename: foo1.ts
export function x(){
return true;
}
// @Filename: foo2.ts
import foo1 = require('./foo1');
var x = foo1.x;
export = x;
// @Filename: foo3.ts
import foo2 = require('./foo2');
var x = foo2(); // should be boolean | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignTypes.ts | TypeScript | // @Filename: expString.ts
var x = "test";
export = x;
// @Filename: expNumber.ts
var x = 42;
export = x;
// @Filename: expBoolean.ts
var x = true;
export = x;
// @Filename: expArray.ts
var x = [1,2];
export = x;
// @Filename: expObject.ts
var x = { answer: 42, when: 1776};
export = x;
// @Filename: expAny.ts
var x;
export = x;
// @Filename: expGeneric.ts
function x<T>(a: T){
return a;
}
export = x;
// @Filename: consumer.ts
import iString = require('./expString');
var v1: string = iString;
import iNumber = require('./expNumber');
var v2: number = iNumber;
import iBoolean = require('./expBoolean');
var v3: boolean = iBoolean;
import iArray = require('./expArray');
var v4: Array<number> = iArray;
import iObject = require('./expObject');
var v5: Object = iObject;
import iAny = require('./expAny');
var v6 = iAny;
import iGeneric = require('./expGeneric');
var v7: {<x>(p1: x): x} = iGeneric;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignmentAndDeclaration.ts | TypeScript | // @module: amd
// @Filename: foo_0.ts
export enum E1 {
A,B,C
}
class C1 {
}
// Invalid, as there is already an exported member.
export = C1; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignmentCircularModules.ts | TypeScript | // @module: amd
// @Filename: foo_0.ts
import foo1 = require('./foo_1');
module Foo {
export var x = foo1.x;
}
export = Foo;
// @Filename: foo_1.ts
import foo2 = require("./foo_2");
module Foo {
export var x = foo2.x;
}
export = Foo;
// @Filename: foo_2.ts
import foo0 = require("./foo_0");
module Foo {
export var x = foo0.x;
}
export = Foo;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignmentConstrainedGenericType.ts | TypeScript | // @module: commonjs
// @Filename: foo_0.ts
class Foo<T extends {a: string; b:number;}>{
test: T;
constructor(x: T){}
}
export = Foo;
// @Filename: foo_1.ts
import foo = require("./foo_0");
var x = new foo(true); // Should error
var y = new foo({a: "test", b: 42}); // Should be OK
var z: number = y.test.b; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignmentGenericType.ts | TypeScript | // @module: commonjs
// @Filename: foo_0.ts
class Foo<T>{
test: T;
}
export = Foo;
// @Filename: foo_1.ts
import foo = require("./foo_0");
var x = new foo<number>();
var y:number = x.test;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignmentMergedInterface.ts | TypeScript | // @module: amd
// @Filename: foo_0.ts
interface Foo {
(a: string): void;
b: string;
}
interface Foo {
(a: number): number;
c: boolean;
d: {x: number; y: number};
}
export = Foo;
// @Filename: foo_1.ts
import foo = require("./foo_0");
var x: foo;
x("test");
x(42);
var y: string = x.b;
if(!!x.c){ }
var z = {x: 1, y: 2};
z = x.d; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignmentMergedModule.ts | TypeScript | // @module: commonjs
// @Filename: foo_0.ts
module Foo {
export function a(){
return 5;
}
export var b = true;
}
module Foo {
export function c(a: number){
return a;
}
export module Test {
export var answer = 42;
}
}
export = Foo;
// @Filename: foo_1.ts
import foo = require("./foo_0");
var a: number = foo.a();
if(!!foo.b){
foo.Test.answer = foo.c(42);
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignmentOfExportNamespaceWithDefault.ts | TypeScript | // @esModuleInterop: true
// @target: esnext
// @filename: main.ts
// @module: commonjs
// https://github.com/microsoft/TypeScript/issues/39149
import a from "a";
a();
// @filename: external.d.ts
declare module "b" {
export function a(): void;
export namespace a {
var _a: typeof a;
export { _a as default };
}
export default a;
}
declare module "a" {
import { a } from "b";
export = a;
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignmentTopLevelClodule.ts | TypeScript | // @module: amd
// @Filename: foo_0.ts
class Foo {
test = "test";
}
module Foo {
export var answer = 42;
}
export = Foo;
// @Filename: foo_1.ts
import foo = require("./foo_0");
if(foo.answer === 42){
var x = new foo();
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignmentTopLevelEnumdule.ts | TypeScript | // @module: amd
// @Filename: foo_0.ts
enum foo {
red, green, blue
}
module foo {
export var answer = 42;
}
export = foo;
// @Filename: foo_1.ts
import foo = require("./foo_0");
var color: foo;
if(color === foo.green){
color = foo.answer;
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignmentTopLevelFundule.ts | TypeScript | // @module: amd
// @Filename: foo_0.ts
function foo() {
return "test";
}
module foo {
export var answer = 42;
}
export = foo;
// @Filename: foo_1.ts
import foo = require("./foo_0");
if(foo.answer === 42){
var x = foo();
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportAssignmentTopLevelIdentifier.ts | TypeScript | // @module: amd
// @Filename: foo_0.ts
module Foo {
export var answer = 42;
}
export = Foo;
// @Filename: foo_1.ts
import foo = require("./foo_0");
if(foo.answer === 42){
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportBinding.ts | TypeScript | // @filename: exportConsts.ts
// @strict: true
export { x }
export { x as xx }
export default x;
const x = 'x'
export { Y as Z }
class Y {}
// @filename: exportVars.ts
// @strict: true
export { y }
export { y as yy }
export default y;
var y = 'y'
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportClassNameWithObjectAMD.ts | TypeScript | // @target: ES5
// @module: amd
export class Object {}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportClassNameWithObjectCommonJS.ts | TypeScript | // @target: ES5
// @module: commonjs
export class Object {}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportClassNameWithObjectSystem.ts | TypeScript | // @target: ES5
// @module: system
export class Object {}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportClassNameWithObjectUMD.ts | TypeScript | // @target: ES5
// @module: umd
export class Object {}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportCodeGen.ts | TypeScript |
// should replace all refs to 'x' in the body,
// with fully qualified
module A {
export var x = 12;
function lt12() {
return x < 12;
}
}
// should not fully qualify 'x'
module B {
var x = 12;
function lt12() {
return x < 12;
}
}
// not copied, since not exported
module C {
function no() {
return false;
}
}
// copies, since exported
module D {
export function yes() {
return true;
}
}
// validate all exportable statements
module E {
export enum Color { Red }
export function fn() { }
export interface I { id: number }
export class C { name: string }
export module M {
export var x = 42;
}
}
// validate all exportable statements,
// which are not exported
module F {
enum Color { Red }
function fn() { }
interface I { id: number }
class C { name: string }
module M {
var x = 42;
}
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportDeclaration.ts | TypeScript | // @module: commonjs
// @isolatedModules: false, true
// @Filename: /a.ts
class A {}
export type { A };
// @Filename: /b.ts
import { A } from './a';
declare const a: A;
new A();
// @Filename: /c.ts
import type { A } from './a';
export = A;
// @Filename: /d.ts
import { A } from './a';
export = A; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportDeclaration_moduleSpecifier-isolatedModules.ts | TypeScript | // @isolatedModules: true
// @Filename: /a.ts
export type A = {};
// @Filename: /b.ts
export type { A } from './a'; // should not error, but would without `type`
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportDeclaration_moduleSpecifier.ts | TypeScript | // @Filename: /a.ts
export class A {}
// @Filename: /b.ts
export type { A } from './a';
// @Filename: /c.ts
import { A } from './b';
declare const a: A;
new A();
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportDeclaration_value.ts | TypeScript | // @Filename: /a.ts
const A = {};
export type { A };
export const AA = {};
// @Filename: /b.ts
export type { AA } from './a';
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportDeclaredModule.ts | TypeScript | // @Filename: foo1.ts
declare module M1 {
export var a: string;
export function b(): number;
}
export = M1;
// @Filename: foo2.ts
import foo1 = require('./foo1');
var x: number = foo1.b(); | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportDefaultClassNameWithObject.ts | TypeScript | // @target: ES5
export default class Object {}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportDefaultClassWithStaticPropertyAssignmentsInES6.ts | TypeScript | // @target:es6
export default class {
static z: string = "Foo";
} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportDefaultExpressionComments.ts | TypeScript | // @declaration: true
/**
* JSDoc Comments
*/
export default null
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportDefaultInJsFile01.ts | TypeScript | // @allowJS: true
// @target: es5
// @module: commonjs
// @filename: myFile01.js
export default "hello"; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportDefaultInJsFile02.ts | TypeScript | // @allowJS: true
// @target: es2015
// @module: es2015
// @filename: myFile02.js
export default "hello"; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportDefaultNamespace.ts | TypeScript | // @declaration: true
export default function someFunc() {
return 'hello!';
}
someFunc.someProp = 'yo';
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportImportAlias.ts | TypeScript | // expect no errors here
module A {
export var x = 'hello world'
export class Point {
constructor(public x: number, public y: number) { }
}
export module B {
export interface Id {
name: string;
}
}
}
module C {
export import a = A;
}
var a: string = C.a.x;
var b: { x: number; y: number; } = new C.a.Point(0, 0);
var c: { name: string };
var c: C.a.B.Id;
module X {
export function Y() {
return 42;
}
export module Y {
export class Point {
constructor(public x: number, public y: number) { }
}
}
}
module Z {
// 'y' should be a fundule here
export import y = X.Y;
}
var m: number = Z.y();
var n: { x: number; y: number; } = new Z.y.Point(0, 0);
module K {
export class L {
constructor(public name: string) { }
}
export module L {
export var y = 12;
export interface Point {
x: number;
y: number;
}
}
}
module M {
export import D = K.L;
}
var o: { name: string };
var o = new M.D('Hello');
var p: { x: number; y: number; }
var p: M.D.Point; | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNamespace1.ts | TypeScript | // @Filename: a.ts
export class A {}
// @Filename: b.ts
export type { A } from './a';
// @Filename: c.ts
export * from './b';
// @Filename: d.ts
import { A } from './c';
new A(); // Error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNamespace10.ts | TypeScript | // @Filename: /a.ts
export class A {}
// @Filename: /b.ts
export type * as ns from "./a";
// @Filename: /c.ts
import { ns } from "./b";
let _: ns.A = new ns.A(); // Error | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNamespace11.ts | TypeScript | // @filename: main.ts
import * as intermediate from './intermediate'
const ghost: intermediate.Ghost = new intermediate.Ghost()
// @filename: intermediate.ts
export type * from './ghost'
// @filename: ghost.ts
export class Ghost {} | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNamespace12.ts | TypeScript | // @filename: main.ts
import { c } from './types'
import * as types from './types'
console.log(c) // Fails as expected, import is still allowed though.
console.log(types.c) // Expected an error here.
// @filename: types.ts
export type * from './values'
// @filename: values.ts
export const c = 10 | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNamespace3.ts | TypeScript | // @Filename: a.ts
export class A {}
// @Filename: b.ts
export type { A } from './a';
// @Filename: c.ts
export * as a from './b';
// @Filename: d.ts
import { a } from './c';
new a.A(); // Error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNamespace4.ts | TypeScript | // @declaration: true
// @Filename: a.ts
export class A {}
// @Filename: b.ts
export type * from './a';
// @Filename: c.ts
export type * as ns from './a';
// @Filename: d.ts
import { A } from './b';
A;
// @Filename: e.ts
import { ns } from './c';
ns.A;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNamespace5.ts | TypeScript | // @declaration: true
// @Filename: /a.ts
export class A {}
export class B {}
export class X {}
// @Filename: /b.ts
export type * from "./a";
export { X } from "./a";
// @Filename: /c.ts
import { A, B as C, X } from "./b";
let _: A = new A(); // Error
let __: C = new C(); // Error
let ___: X = new X(); // Ok
// @Filename: /d.ts
export type * from "./a";
export * from "./a";
// @Filename: /e.ts
import { A, B, X } from "./d";
let _: A = new A(); // Ok
let __: B = new B(); // Ok
let ___: X = new X(); // Ok | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNamespace6.ts | TypeScript | // @Filename: /a.ts
export class A {}
export class B {}
// @Filename: /b.ts
export type * from "./a";
// @Filename: /c.ts
export * from "./b";
// @Filename: /d.ts
import { A, B } from "./c";
let _: A = new A(); // Error
let __: B = new B(); // Error | willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNamespace7.ts | TypeScript | // @Filename: /a.ts
export class A {}
export class B {}
export class C {}
// @Filename: /b.ts
export type * from "./a";
export class C {}
// @Filename: /c.ts
import { A, B, C } from "./b";
let _: A = new A(); // Error
let __: B = new B(); // Error
let ___: C = new C(); // Ok
// @Filename: /d.ts
export type * from "./b";
// @Filename: /e.ts
import { A, B, C } from "./d";
let _: A = new A(); // Error
let __: B = new B(); // Error
let ___: C = new C(); // Error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNamespace8.ts | TypeScript | // @Filename: /a.ts
export class A {}
export class B {}
// @Filename: /b.ts
export class B {}
export class C {}
// @Filename: /c.ts
export type * from "./a";
export * from "./b"; // Collision error
// @Filename: /d.ts
import { A, B, C } from "./c";
let _: A = new A(); // Error
let __: B = new B(); // Ok
let ___: C = new C(); // Ok
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNamespace9.ts | TypeScript | // @Filename: /a.ts
export type A = number;
// @Filename: /b.ts
export type * from "./a";
// @Filename: /c.ts
import { A } from "./b";
const A = 1;
export { A };
// @Filename: /d.ts
import { A } from "./c";
A; // Ok
type _ = A;
// @Filename: /e.ts
export const A = 1;
// @Filename: /f.ts
export * from "./e";
export type * from "./a"; // Collision error
// @Filename: /g.ts
import { A } from "./f";
A;
type _ = A; // Follow-on from collision error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNamespace_js.ts | TypeScript | // @declaration: true
// @outDir: out
// @checkJs: true
// @allowJs: true
// @Filename: a.js
export class A {}
// @Filename: b.js
export type * from './a';
// @Filename: c.js
import { A } from './b';
A;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNestedNamespaces.ts | TypeScript | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @Filename: mod.js
exports.n = {};
exports.n.K = function () {
this.x = 10;
}
exports.Classic = class {
constructor() {
this.p = 1
}
}
// @Filename: use.js
import * as s from './mod'
var k = new s.n.K()
k.x
var classic = new s.Classic()
/** @param {s.n.K} c
@param {s.Classic} classic */
function f(c, classic) {
c.x
classic.p
}
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNestedNamespaces2.ts | TypeScript | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @Filename: mod.js
// Based on a pattern from adonis
exports.formatters = {}
// @Filename: first.js
exports = require('./mod')
exports.formatters.j = function (v) {
return v
}
// @Filename: second.js
exports = require('./mod')
exports.formatters.o = function (v) {
return v
}
// @Filename: use.js
import * as debug from './mod'
debug.formatters.j
var one = debug.formatters.o(1)
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNonLocalDeclarations.ts | TypeScript | export { string };
export type { number };
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportNonVisibleType.ts | TypeScript | // @Filename: foo1.ts
interface I1 {
a: string;
b: number;
}
var x: I1 = {a: "test", b: 42};
export = x; // Should fail, I1 not exported.
// @Filename: foo2.ts
interface I1 {
a: string;
b: number;
}
class C1 {
m1: I1;
}
export = C1; // Should fail, type I1 of visible member C1.m1 not exported.
// @Filename: foo3.ts
interface I1 {
a: string;
b: number;
}
class C1 {
private m1: I1;
}
export = C1; // Should work, private type I1 of visible class C1 only used in private member m1.
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportPropertyAssignmentNameResolution.ts | TypeScript | // @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: bug24492.js
module.exports.D = class { }
new D()
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportSpecifiers.ts | TypeScript | // @module: esnext
// @declaration: true
// @Filename: /imports.ts
import { type, as, something, foo, bar } from "./exports.js";
type;
as; // Error (used in emitting position)
something; // Error (used in emitting position)
foo; // Error (used in emitting position)
bar; // Error (used in emitting position)
// @Filename: /exports.ts
const type = 0;
const as = 0;
const something = 0;
export { type };
export { type as };
export { type something };
export { type type as foo };
export { type as as bar };
export type { type something as whatever }; // Error
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportSpecifiers_js.ts | TypeScript | // @allowJs: true
// @checkJs: true
// @noEmit: true
// @Filename: ./a.js
const foo = 0;
export { type foo };
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportSpellingSuggestion.ts | TypeScript | // @filename: a.ts
export function assertNever(x: never, msg: string) {
throw new Error("Unexpected " + msg);
}
// @filename: b.ts
import { assertNevar } from "./a";
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportStar-amd.ts | TypeScript | // @module: amd
// @target: ES5
// @filename: t1.ts
export var x = 1;
export var y = 2;
// @filename: t2.ts
export default "hello";
export function foo() { }
// @filename: t3.ts
var x = "x";
var y = "y";
var z = "z";
export { x, y, z };
// @filename: t4.ts
export * from "./t1";
export * from "./t2";
export * from "./t3";
// @filename: main.ts
import hello, { x, y, z, foo } from "./t4";
hello;
x;
y;
z;
foo;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportStar.ts | TypeScript | // @module: commonjs
// @target: ES5
// @filename: t1.ts
export var x = 1;
export var y = 2;
// @filename: t2.ts
export default "hello";
export function foo() { }
// @filename: t3.ts
var x = "x";
var y = "y";
var z = "z";
export { x, y, z };
// @filename: t4.ts
export * from "./t1";
export * from "./t2";
export * from "./t3";
// @filename: main.ts
import hello, { x, y, z, foo } from "./t4";
hello;
x;
y;
z;
foo;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportTypeMergedWithExportStarAsNamespace.ts | TypeScript | // @Filename: usage.ts
import { Something } from "./prelude"
export const myValue: Something<string> = Something.of("abc")
export type MyType = Something.SubType<string>
// @Filename: Something.ts
export type Something<A> = { value: A }
export type SubType<A> = { value: A }
export declare function of<A>(value: A): Something<A>
// @Filename: prelude.ts
import * as S from "./Something"
export * as Something from "./Something"
export type Something<A> = S.Something<A>
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportedAliasedEnumTag.ts | TypeScript | // @noemit: true
// @allowjs: true
// @filename: exportedAliasedEnumTag.js
var middlewarify = module.exports = {};
/** @enum */
middlewarify.Type = {
BEFORE: 'before'
};
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportedEnumTypeAndValue.ts | TypeScript | // @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: def.js
/** @enum {number} */
const MyEnum = {
a: 1,
b: 2
};
export default MyEnum;
// @Filename: use.js
import MyEnum from "./def";
/** @type {MyEnum} */
const v = MyEnum.b;
| willcrichton/ilc-swc | 1 | Rust | willcrichton | Will Crichton | Brown University | |
crates/swc_ecma_parser/tests/tsc/exportsAndImports1-amd.ts | TypeScript | // @module: amd
// @target: ES5
// @filename: t1.ts
var v = 1;
function f() { }
class C {
}
interface I {
}
enum E {
A, B, C
}
const enum D {
A, B, C
}
module M {
export var x;
}
module N {
export interface I {
}
}
type T = number;
import a = M.x;
export { v, f, C, I, E, D, M, N, T, a };
// @filename: t2.ts
export { v, f, C, I, E, D, M, N, T, a } from "./t1";
// @filename: t3.ts
import { v, f, C, I, E, D, M, N, T, a } from "./t1";
export { v, f, C, I, E, D, M, N, T, a };
| 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.