-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(es/typescript): Verify TypeScript stripped output
- Loading branch information
1 parent
12e091d
commit 0ac8906
Showing
99 changed files
with
1,580 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
crates/swc_fast_ts_strip/tests/fixture/test-case-1.strip.swc-stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
x The angle-bracket syntax for type assertions, `<T>expr`, is not supported in type strip mode. Instead, use the 'as' syntax: `expr as T`. | ||
,-[7:1] | ||
6 | | ||
7 | (<string>"test"); | ||
: ^^^^^^^^^^^^^^ | ||
8 | //^^^^^^^^ | ||
`---- |
7 changes: 7 additions & 0 deletions
7
crates/swc_fast_ts_strip/tests/fixture/unicode.strip.swc-stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
x The angle-bracket syntax for type assertions, `<T>expr`, is not supported in type strip mode. Instead, use the 'as' syntax: `expr as T`. | ||
,-[4:1] | ||
3 | function foo() { | ||
4 | <任意>(void 1); throw new Error('foo'); | ||
: ^^^^^^^^^^^^^^ | ||
5 | } | ||
`---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
x Unexpected token `constructor`. Expected * for generator, private key, identifier or async | ||
,-[$DIR/tests/tsc/Protected3.strip.js:2:1] | ||
1 | class C { | ||
2 | protected constructor() { } | ||
: ^^^^^^^^^^^ | ||
3 | } | ||
`---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class C { | ||
protected constructor() { } | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/swc_fast_ts_strip/tests/tsc/accessorsOverrideProperty9.strip.broken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
x Unexpected token `constructor`. Expected * for generator, private key, identifier or async | ||
,-[$DIR/tests/tsc/accessorsOverrideProperty9.strip.js:31:1] | ||
30 | class MixedClass extends baseClass { | ||
31 | public constructor(...args ) { | ||
: ^^^^^^^^^^^ | ||
32 | super(...args); | ||
`---- |
49 changes: 49 additions & 0 deletions
49
crates/swc_fast_ts_strip/tests/tsc/accessorsOverrideProperty9.strip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// @strict: true | ||
// @target: es2017 | ||
// #41347, based on microsoft/rushstack | ||
|
||
// Mixin utilities | ||
|
||
|
||
|
||
|
||
|
||
// Base class | ||
class ApiItem { | ||
get members() { | ||
return []; | ||
} | ||
} | ||
|
||
// Normal subclass | ||
class ApiEnumMember extends ApiItem { | ||
} | ||
|
||
// Mixin base class | ||
|
||
|
||
|
||
|
||
function ApiItemContainerMixin ( | ||
baseClass | ||
) { | ||
class MixedClass extends baseClass { | ||
public constructor(...args ) { | ||
super(...args); | ||
} | ||
|
||
get members() { | ||
return []; | ||
} | ||
} | ||
|
||
return MixedClass; | ||
} | ||
|
||
// Subclass inheriting from mixin | ||
export class ApiEnum extends ApiItemContainerMixin(ApiItem) { | ||
// This worked prior to TypeScript 4.0: | ||
get members() { | ||
return []; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/swc_fast_ts_strip/tests/tsc/autoAccessor7.strip.broken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
x Unexpected token `accessor`. Expected * for generator, private key, identifier or async | ||
,-[$DIR/tests/tsc/autoAccessor7.strip.js:5:1] | ||
4 | class C1 { | ||
5 | abstract accessor a ; | ||
: ^^^^^^^^ | ||
6 | } | ||
`---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// @target: esnext, es2022, es2015 | ||
// @useDefineForClassFields: * | ||
|
||
class C1 { | ||
abstract accessor a ; | ||
} | ||
|
||
class C2 extends C1 { | ||
accessor a = 1; | ||
} | ||
|
||
class C3 extends C1 { | ||
get a() { return 1; } | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/swc_fast_ts_strip/tests/tsc/autoAccessorAllowedModifiers.strip.broken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
x Unexpected token `accessor`. Expected * for generator, private key, identifier or async | ||
,-[$DIR/tests/tsc/autoAccessorAllowedModifiers.strip.js:6:1] | ||
5 | accessor a ; | ||
6 | public accessor b ; | ||
: ^^^^^^^^ | ||
7 | private accessor c ; | ||
`---- |
29 changes: 29 additions & 0 deletions
29
crates/swc_fast_ts_strip/tests/tsc/autoAccessorAllowedModifiers.strip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// @target: esnext | ||
// @noTypesAndSymbols: true | ||
|
||
class C1 { | ||
accessor a ; | ||
public accessor b ; | ||
private accessor c ; | ||
protected accessor d ; | ||
abstract accessor e ; | ||
static accessor f ; | ||
public static accessor g ; | ||
private static accessor h ; | ||
protected static accessor i ; | ||
accessor #j ; | ||
accessor "k" ; | ||
accessor 108 ; | ||
accessor ["m"] ; | ||
accessor n! ; | ||
} | ||
|
||
class C2 extends C1 { | ||
override accessor e ; | ||
static override accessor i ; | ||
} | ||
|
||
|
||
|
||
|
||
|
7 changes: 7 additions & 0 deletions
7
crates/swc_fast_ts_strip/tests/tsc/callChainWithSuper.strip.broken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
x Unexpected token `?`. Expected * for generator, private key, identifier or async | ||
,-[$DIR/tests/tsc/callChainWithSuper.strip.js:6:1] | ||
5 | // GH#34952 | ||
6 | class Base { method?() {} } | ||
: ^ | ||
7 | class Derived extends Base { | ||
`---- |
10 changes: 10 additions & 0 deletions
10
crates/swc_fast_ts_strip/tests/tsc/callChainWithSuper.strip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// @target: *,-es3 | ||
// @strict: true | ||
// @noTypesAndSymbols: true | ||
|
||
// GH#34952 | ||
class Base { method?() {} } | ||
class Derived extends Base { | ||
method1() { return super.method?.(); } | ||
method2() { return super["method"]?.(); } | ||
} |
6 changes: 6 additions & 0 deletions
6
crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility4.strip.broken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
x Unexpected token `constructor`. Expected * for generator, private key, identifier or async | ||
,-[$DIR/tests/tsc/classConstructorAccessibility4.strip.js:4:1] | ||
3 | class A { | ||
4 | private constructor() { } | ||
: ^^^^^^^^^^^ | ||
`---- |
31 changes: 31 additions & 0 deletions
31
crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility4.strip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// @declaration: true | ||
|
||
class A { | ||
private constructor() { } | ||
|
||
method() { | ||
class B { | ||
method() { | ||
new A(); // OK | ||
} | ||
} | ||
|
||
class C extends A { // OK | ||
} | ||
} | ||
} | ||
|
||
class D { | ||
protected constructor() { } | ||
|
||
method() { | ||
class E { | ||
method() { | ||
new D(); // OK | ||
} | ||
} | ||
|
||
class F extends D { // OK | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility5.strip.broken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
x Unexpected token `constructor`. Expected * for generator, private key, identifier or async | ||
,-[$DIR/tests/tsc/classConstructorAccessibility5.strip.js:2:1] | ||
1 | class Base { | ||
2 | protected constructor() { } | ||
: ^^^^^^^^^^^ | ||
3 | } | ||
`---- |
10 changes: 10 additions & 0 deletions
10
crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility5.strip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Base { | ||
protected constructor() { } | ||
} | ||
class Derived extends Base { | ||
static make() { new Base() } // ok | ||
} | ||
|
||
class Unrelated { | ||
static fake() { new Base() } // error | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/swc_fast_ts_strip/tests/tsc/classConstructorOverloadsAccessibility.strip.broken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
x Unexpected token `constructor`. Expected * for generator, private key, identifier or async | ||
,-[$DIR/tests/tsc/classConstructorOverloadsAccessibility.strip.js:4:1] | ||
3 | class A { | ||
4 | public constructor(a ) // error | ||
: ^^^^^^^^^^^ | ||
5 | protected constructor(a ) // error | ||
`---- |
34 changes: 34 additions & 0 deletions
34
crates/swc_fast_ts_strip/tests/tsc/classConstructorOverloadsAccessibility.strip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// @declaration: true | ||
|
||
class A { | ||
public constructor(a ) // error | ||
protected constructor(a ) // error | ||
private constructor(a ) | ||
private constructor() { | ||
|
||
} | ||
} | ||
|
||
class B { | ||
protected constructor(a ) // error | ||
constructor(a ) | ||
constructor() { | ||
|
||
} | ||
} | ||
|
||
class C { | ||
protected constructor(a ) | ||
protected constructor(a ) | ||
protected constructor() { | ||
|
||
} | ||
} | ||
|
||
class D { | ||
constructor(a ) | ||
constructor(a ) | ||
public constructor() { | ||
|
||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/swc_fast_ts_strip/tests/tsc/classWithOptionalParameter.strip.broken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
x Unexpected token `?`. Expected * for generator, private key, identifier or async | ||
,-[$DIR/tests/tsc/classWithOptionalParameter.strip.js:5:1] | ||
4 | x ; | ||
5 | f?() {} | ||
: ^ | ||
6 | } | ||
`---- |
Oops, something went wrong.