babel-generator: Add TypeScript support (#5896)
* babel-generator: Add TypeScript support * Remove type declarations; not published from babylon * Remove TODOs * Consistently use `this.word` for tokens that are words
This commit is contained in:
1
packages/babel-generator/test/fixtures/typescript/arrow-function-annotated/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/arrow-function-annotated/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(x: number): number => x;
|
||||
1
packages/babel-generator/test/fixtures/typescript/arrow-function-annotated/expected.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/arrow-function-annotated/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(x: number): number => x;
|
||||
@@ -0,0 +1,2 @@
|
||||
async < 1;
|
||||
async<T>() == 0;
|
||||
@@ -0,0 +1,2 @@
|
||||
async < 1;
|
||||
async<T>() == 0;
|
||||
1
packages/babel-generator/test/fixtures/typescript/arrow-function-async-generic/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/arrow-function-async-generic/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
async <T>(a: T): T => a;
|
||||
1
packages/babel-generator/test/fixtures/typescript/arrow-function-async-generic/expected.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/arrow-function-async-generic/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
async <T>(a: T): T => a;
|
||||
1
packages/babel-generator/test/fixtures/typescript/arrow-function-async/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/arrow-function-async/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
async (x?: number): any => x;
|
||||
1
packages/babel-generator/test/fixtures/typescript/arrow-function-async/expected.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/arrow-function-async/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
async (x?: number): any => x;
|
||||
@@ -0,0 +1 @@
|
||||
(x: number = 0) => 0;
|
||||
@@ -0,0 +1 @@
|
||||
(x: number = 0) => 0;
|
||||
1
packages/babel-generator/test/fixtures/typescript/arrow-function-destructuring/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/arrow-function-destructuring/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
({ a = 0 }) => 0;
|
||||
3
packages/babel-generator/test/fixtures/typescript/arrow-function-destructuring/expected.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/arrow-function-destructuring/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
({
|
||||
a = 0
|
||||
}) => 0;
|
||||
2
packages/babel-generator/test/fixtures/typescript/arrow-function-generic-tsx/actual.js
vendored
Normal file
2
packages/babel-generator/test/fixtures/typescript/arrow-function-generic-tsx/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// Same as `generic`. Verify that JSX doesn't change things.
|
||||
<T>(a: T): T => a;
|
||||
2
packages/babel-generator/test/fixtures/typescript/arrow-function-generic-tsx/expected.js
vendored
Normal file
2
packages/babel-generator/test/fixtures/typescript/arrow-function-generic-tsx/expected.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// Same as `generic`. Verify that JSX doesn't change things.
|
||||
<T>(a: T): T => a;
|
||||
3
packages/babel-generator/test/fixtures/typescript/arrow-function-generic-tsx/options.json
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/arrow-function-generic-tsx/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["jsx", "typescript"]
|
||||
}
|
||||
1
packages/babel-generator/test/fixtures/typescript/arrow-function-generic/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/arrow-function-generic/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<T>(a: T): T => a;
|
||||
1
packages/babel-generator/test/fixtures/typescript/arrow-function-generic/expected.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/arrow-function-generic/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<T>(a: T): T => a;
|
||||
@@ -0,0 +1 @@
|
||||
(x?: number): any => x;
|
||||
@@ -0,0 +1 @@
|
||||
(x?: number): any => x;
|
||||
1
packages/babel-generator/test/fixtures/typescript/arrow-function-predicate-types/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/arrow-function-predicate-types/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(x: any): x is string => true;
|
||||
1
packages/babel-generator/test/fixtures/typescript/arrow-function-predicate-types/expected.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/arrow-function-predicate-types/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(x: any): x is string => true;
|
||||
4
packages/babel-generator/test/fixtures/typescript/cast-as/actual.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/cast-as/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
x as T;
|
||||
x < y as boolean; // (x < y) as boolean;
|
||||
x === 1 as number; // x === (1 as number);
|
||||
x as any as T;
|
||||
6
packages/babel-generator/test/fixtures/typescript/cast-as/expected.js
vendored
Normal file
6
packages/babel-generator/test/fixtures/typescript/cast-as/expected.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
(x as T);
|
||||
(x < y as boolean); // (x < y) as boolean;
|
||||
|
||||
x === (1 as number); // x === (1 as number);
|
||||
|
||||
((x as any) as T);
|
||||
1
packages/babel-generator/test/fixtures/typescript/cast-false-positive/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/cast-false-positive/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
f(x < 0, /a/);
|
||||
1
packages/babel-generator/test/fixtures/typescript/cast-false-positive/expected.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/cast-false-positive/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
f(x < 0, /a/);
|
||||
3
packages/babel-generator/test/fixtures/typescript/cast-need-parentheses/actual.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/cast-need-parentheses/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
(<T> x).y;
|
||||
(x as T).y;
|
||||
x!.y;
|
||||
3
packages/babel-generator/test/fixtures/typescript/cast-need-parentheses/expected.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/cast-need-parentheses/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
(<T> x).y;
|
||||
(x as T).y;
|
||||
x!.y;
|
||||
@@ -0,0 +1 @@
|
||||
x!.y;
|
||||
@@ -0,0 +1 @@
|
||||
x!.y;
|
||||
1
packages/babel-generator/test/fixtures/typescript/cast-null-assertion/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/cast-null-assertion/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
x!;
|
||||
1
packages/babel-generator/test/fixtures/typescript/cast-null-assertion/expected.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/cast-null-assertion/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
x!;
|
||||
@@ -0,0 +1 @@
|
||||
1 + <number> 1;
|
||||
@@ -0,0 +1 @@
|
||||
1 + (<number> 1);
|
||||
@@ -0,0 +1 @@
|
||||
<number> 1 + 1;
|
||||
@@ -0,0 +1 @@
|
||||
(<number> 1) + 1;
|
||||
1
packages/babel-generator/test/fixtures/typescript/cast-type-assertion/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/cast-type-assertion/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<number> 1;
|
||||
1
packages/babel-generator/test/fixtures/typescript/cast-type-assertion/expected.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/cast-type-assertion/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(<number> 1);
|
||||
6
packages/babel-generator/test/fixtures/typescript/class-abstract/actual.js
vendored
Normal file
6
packages/babel-generator/test/fixtures/typescript/class-abstract/actual.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
abstract class C {}
|
||||
declare abstract class C {}
|
||||
export abstract class C {}
|
||||
// `export abstract class { }` is not valid.
|
||||
// `export default abstract class C { }` is not valid.
|
||||
// `abstract class` is not valid as an expression.
|
||||
7
packages/babel-generator/test/fixtures/typescript/class-abstract/expected.js
vendored
Normal file
7
packages/babel-generator/test/fixtures/typescript/class-abstract/expected.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
abstract class C {}
|
||||
|
||||
declare abstract class C {}
|
||||
|
||||
export abstract class C {} // `export abstract class { }` is not valid.
|
||||
// `export default abstract class C { }` is not valid.
|
||||
// `abstract class` is not valid as an expression.
|
||||
5
packages/babel-generator/test/fixtures/typescript/class-constructor/actual.js
vendored
Normal file
5
packages/babel-generator/test/fixtures/typescript/class-constructor/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
constructor(x: number, y: number);
|
||||
constructor(x: string, y: string);
|
||||
constructor(x: any, y: any) {}
|
||||
}
|
||||
7
packages/babel-generator/test/fixtures/typescript/class-constructor/expected.js
vendored
Normal file
7
packages/babel-generator/test/fixtures/typescript/class-constructor/expected.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
constructor(x: number, y: number);
|
||||
constructor(x: string, y: string);
|
||||
|
||||
constructor(x: any, y: any) {}
|
||||
|
||||
}
|
||||
7
packages/babel-generator/test/fixtures/typescript/class-declare/actual.js
vendored
Normal file
7
packages/babel-generator/test/fixtures/typescript/class-declare/actual.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
declare class C {
|
||||
[x: string]: any;
|
||||
x;
|
||||
x: number;
|
||||
f();
|
||||
f(): void;
|
||||
}
|
||||
7
packages/babel-generator/test/fixtures/typescript/class-declare/expected.js
vendored
Normal file
7
packages/babel-generator/test/fixtures/typescript/class-declare/expected.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
declare class C {
|
||||
[x: string]: any;
|
||||
x;
|
||||
x: number;
|
||||
f();
|
||||
f(): void;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
(class extends f()<T> implements X.Y<T> {});
|
||||
(class C extends f()<T> implements X.Y<T> {});
|
||||
@@ -0,0 +1,3 @@
|
||||
(class extends f()<T> implements X.Y<T> {});
|
||||
|
||||
(class C extends f()<T> implements X.Y<T> {});
|
||||
2
packages/babel-generator/test/fixtures/typescript/class-expression-extends/actual.js
vendored
Normal file
2
packages/babel-generator/test/fixtures/typescript/class-expression-extends/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
(class extends f()<T> {});
|
||||
(class C extends f()<T> {});
|
||||
3
packages/babel-generator/test/fixtures/typescript/class-expression-extends/expected.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/class-expression-extends/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
(class extends f()<T> {});
|
||||
|
||||
(class C extends f()<T> {});
|
||||
2
packages/babel-generator/test/fixtures/typescript/class-expression-generic/actual.js
vendored
Normal file
2
packages/babel-generator/test/fixtures/typescript/class-expression-generic/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
(class<T> {});
|
||||
(class C<T> {});
|
||||
3
packages/babel-generator/test/fixtures/typescript/class-expression-generic/expected.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/class-expression-generic/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
(class<T> {});
|
||||
|
||||
(class C<T> {});
|
||||
2
packages/babel-generator/test/fixtures/typescript/class-expression-implements/actual.js
vendored
Normal file
2
packages/babel-generator/test/fixtures/typescript/class-expression-implements/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
(class implements X.Y<T> {});
|
||||
(class C implements X.Y<T> {});
|
||||
3
packages/babel-generator/test/fixtures/typescript/class-expression-implements/expected.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/class-expression-implements/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
(class implements X.Y<T> {});
|
||||
|
||||
(class C implements X.Y<T> {});
|
||||
1
packages/babel-generator/test/fixtures/typescript/class-extends-implements/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/class-extends-implements/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
class C extends f()<T> implements X.Y<T> {}
|
||||
1
packages/babel-generator/test/fixtures/typescript/class-extends-implements/expected.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/class-extends-implements/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
class C extends f()<T> implements X.Y<T> {}
|
||||
1
packages/babel-generator/test/fixtures/typescript/class-extends/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/class-extends/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
class C extends f()<T> {}
|
||||
1
packages/babel-generator/test/fixtures/typescript/class-extends/expected.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/class-extends/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
class C extends f()<T> {}
|
||||
1
packages/babel-generator/test/fixtures/typescript/class-generic/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/class-generic/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
class C<T extends object = { x: number }> {}
|
||||
3
packages/babel-generator/test/fixtures/typescript/class-generic/expected.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/class-generic/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
class C<T extends object = {
|
||||
x: number;
|
||||
}> {}
|
||||
3
packages/babel-generator/test/fixtures/typescript/class-get-generic/actual.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/class-get-generic/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare class C {
|
||||
get<T>(): void;
|
||||
}
|
||||
3
packages/babel-generator/test/fixtures/typescript/class-get-generic/expected.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/class-get-generic/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare class C {
|
||||
get<T>(): void;
|
||||
}
|
||||
1
packages/babel-generator/test/fixtures/typescript/class-implements/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/class-implements/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
class C implements X.Y<T> {}
|
||||
1
packages/babel-generator/test/fixtures/typescript/class-implements/expected.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/class-implements/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
class C implements X.Y<T> {}
|
||||
4
packages/babel-generator/test/fixtures/typescript/class-index-signature/actual.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/class-index-signature/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
[x: string]: any;
|
||||
readonly [x: string]: any;
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/typescript/class-index-signature/expected.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/class-index-signature/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
[x: string]: any;
|
||||
readonly [x: string]: any;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
public(): void;
|
||||
public static(): void;
|
||||
readonly = 0;
|
||||
async<T>(): void;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
public(): void;
|
||||
public static(): void;
|
||||
readonly = 0;
|
||||
async<T>(): void;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class C {
|
||||
public delete(): void;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class C {
|
||||
public delete(): void;
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/typescript/class-method-computed/actual.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/class-method-computed/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
[Symbol.iterator](): void;
|
||||
[Symbol.iterator]?(): void;
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/typescript/class-method-computed/expected.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/class-method-computed/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
[Symbol.iterator](): void;
|
||||
[Symbol.iterator]?(): void;
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/typescript/class-method-generic/actual.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/class-method-generic/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
f<T>(a: T, b?: T, ...c: T[]): T {}
|
||||
[Symbol.iterator]<T>(): T {}
|
||||
}
|
||||
6
packages/babel-generator/test/fixtures/typescript/class-method-generic/expected.js
vendored
Normal file
6
packages/babel-generator/test/fixtures/typescript/class-method-generic/expected.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
f<T>(a: T, b?: T, ...c: T[]): T {}
|
||||
|
||||
[Symbol.iterator]<T>(): T {}
|
||||
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/typescript/class-method-no-body/actual.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/class-method-no-body/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
f();
|
||||
f(): void;
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/typescript/class-method-no-body/expected.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/class-method-no-body/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
f();
|
||||
f(): void;
|
||||
}
|
||||
3
packages/babel-generator/test/fixtures/typescript/class-method-optional/actual.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/class-method-optional/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
class C {
|
||||
m?(): void {}
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/typescript/class-method-optional/expected.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/class-method-optional/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
m?(): void {}
|
||||
|
||||
}
|
||||
3
packages/babel-generator/test/fixtures/typescript/class-method-return-type/actual.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/class-method-return-type/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
class C {
|
||||
f(): void {}
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/typescript/class-method-return-type/expected.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/class-method-return-type/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
f(): void {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class C
|
||||
{
|
||||
m()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
m() {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class C
|
||||
{
|
||||
m()
|
||||
n()
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
m();
|
||||
n();
|
||||
}
|
||||
11
packages/babel-generator/test/fixtures/typescript/class-modifiers-accessors/actual.js
vendored
Normal file
11
packages/babel-generator/test/fixtures/typescript/class-modifiers-accessors/actual.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copy of modifiers-methods with 'get'
|
||||
abstract class C {
|
||||
abstract get a();
|
||||
static get s() { return 0; }
|
||||
public abstract get pua();
|
||||
public static get pus() { return 0; }
|
||||
|
||||
public get pu() { return 0; }
|
||||
protected get po() { return 0; }
|
||||
private get pi() { return 0; }
|
||||
}
|
||||
27
packages/babel-generator/test/fixtures/typescript/class-modifiers-accessors/expected.js
vendored
Normal file
27
packages/babel-generator/test/fixtures/typescript/class-modifiers-accessors/expected.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copy of modifiers-methods with 'get'
|
||||
abstract class C {
|
||||
abstract get a();
|
||||
|
||||
static get s() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public abstract get pua();
|
||||
|
||||
public static get pus() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public get pu() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected get po() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private get pi() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
11
packages/babel-generator/test/fixtures/typescript/class-modifiers-methods-async/actual.js
vendored
Normal file
11
packages/babel-generator/test/fixtures/typescript/class-modifiers-methods-async/actual.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copy of modifiers-methods with 'async'
|
||||
abstract class C {
|
||||
abstract async a();
|
||||
static async s() {}
|
||||
public abstract async pua();
|
||||
public static async pus() {}
|
||||
|
||||
public async pu() {}
|
||||
protected async po() {}
|
||||
private async pi() {}
|
||||
}
|
||||
17
packages/babel-generator/test/fixtures/typescript/class-modifiers-methods-async/expected.js
vendored
Normal file
17
packages/babel-generator/test/fixtures/typescript/class-modifiers-methods-async/expected.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copy of modifiers-methods with 'async'
|
||||
abstract class C {
|
||||
abstract async a();
|
||||
|
||||
static async s() {}
|
||||
|
||||
public abstract async pua();
|
||||
|
||||
public static async pus() {}
|
||||
|
||||
public async pu() {}
|
||||
|
||||
protected async po() {}
|
||||
|
||||
private async pi() {}
|
||||
|
||||
}
|
||||
21
packages/babel-generator/test/fixtures/typescript/class-modifiers-properties/actual.js
vendored
Normal file
21
packages/babel-generator/test/fixtures/typescript/class-modifiers-properties/actual.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
abstract class C {
|
||||
readonly r;
|
||||
readonly r2?: number;
|
||||
abstract a;
|
||||
static s;
|
||||
|
||||
public pu;
|
||||
protected po;
|
||||
private pi;
|
||||
|
||||
readonly abstract ra;
|
||||
abstract readonly ar;
|
||||
static readonly sr;
|
||||
|
||||
public readonly pur;
|
||||
public abstract pua;
|
||||
public static pus;
|
||||
public readonly abstract pura;
|
||||
public abstract readonly puar;
|
||||
public static readonly pusr;
|
||||
}
|
||||
18
packages/babel-generator/test/fixtures/typescript/class-modifiers-properties/expected.js
vendored
Normal file
18
packages/babel-generator/test/fixtures/typescript/class-modifiers-properties/expected.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
abstract class C {
|
||||
readonly r;
|
||||
readonly r2?: number;
|
||||
abstract a;
|
||||
static s;
|
||||
public pu;
|
||||
protected po;
|
||||
private pi;
|
||||
abstract readonly ra;
|
||||
abstract readonly ar;
|
||||
static readonly sr;
|
||||
public readonly pur;
|
||||
public abstract pua;
|
||||
public static pus;
|
||||
public abstract readonly pura;
|
||||
public abstract readonly puar;
|
||||
public static readonly pusr;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class C {
|
||||
constructor(@foo readonly x: number) {}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
constructor(@foo
|
||||
readonly x: number) {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["typescript", "decorators"]
|
||||
}
|
||||
11
packages/babel-generator/test/fixtures/typescript/class-parameter-properties/actual.js
vendored
Normal file
11
packages/babel-generator/test/fixtures/typescript/class-parameter-properties/actual.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
class C {
|
||||
constructor(
|
||||
readonly r,
|
||||
public pu: number,
|
||||
protected po?,
|
||||
private pi?: number,
|
||||
public readonly pur,
|
||||
// Also works on AssignmentPattern
|
||||
readonly x = 0,
|
||||
public y?: number = 0) {}
|
||||
}
|
||||
5
packages/babel-generator/test/fixtures/typescript/class-parameter-properties/expected.js
vendored
Normal file
5
packages/babel-generator/test/fixtures/typescript/class-parameter-properties/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
class C {
|
||||
constructor(readonly r, public pu: number, protected po?, private pi?: number, public readonly pur, // Also works on AssignmentPattern
|
||||
readonly x = 0, public y?: number = 0) {}
|
||||
|
||||
}
|
||||
6
packages/babel-generator/test/fixtures/typescript/class-properties/actual.js
vendored
Normal file
6
packages/babel-generator/test/fixtures/typescript/class-properties/actual.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
x;
|
||||
x?;
|
||||
x: number;
|
||||
x: number = 1;
|
||||
}
|
||||
6
packages/babel-generator/test/fixtures/typescript/class-properties/expected.js
vendored
Normal file
6
packages/babel-generator/test/fixtures/typescript/class-properties/expected.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
x;
|
||||
x?;
|
||||
x: number;
|
||||
x: number = 1;
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/typescript/class-property-computed/actual.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/class-property-computed/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
[Symbol.iterator]: number;
|
||||
[Symbol.iterator]?: number;
|
||||
}
|
||||
4
packages/babel-generator/test/fixtures/typescript/class-property-computed/expected.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/class-property-computed/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
class C {
|
||||
[Symbol.iterator]: number;
|
||||
[Symbol.iterator]?: number;
|
||||
}
|
||||
6
packages/babel-generator/test/fixtures/typescript/class-static/actual.js
vendored
Normal file
6
packages/babel-generator/test/fixtures/typescript/class-static/actual.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
static f();
|
||||
public static f();
|
||||
protected static f();
|
||||
private static f();
|
||||
}
|
||||
6
packages/babel-generator/test/fixtures/typescript/class-static/expected.js
vendored
Normal file
6
packages/babel-generator/test/fixtures/typescript/class-static/expected.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
static f();
|
||||
public static f();
|
||||
protected static f();
|
||||
private static f();
|
||||
}
|
||||
1
packages/babel-generator/test/fixtures/typescript/const-no-initializer/actual.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/const-no-initializer/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
const x: number;
|
||||
1
packages/babel-generator/test/fixtures/typescript/const-no-initializer/expected.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/typescript/const-no-initializer/expected.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
const x: number;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user