diff --git a/crates/swc_fast_ts_strip/src/lib.rs b/crates/swc_fast_ts_strip/src/lib.rs index d5bb8885cea0..bb7313bdb19f 100644 --- a/crates/swc_fast_ts_strip/src/lib.rs +++ b/crates/swc_fast_ts_strip/src/lib.rs @@ -11,13 +11,14 @@ use swc_common::{ BytePos, FileName, Mark, SourceMap, Span, Spanned, }; use swc_ecma_ast::{ - ArrowExpr, BindingIdent, Class, ClassDecl, ClassMethod, ClassProp, Decl, DoWhileStmt, - EsVersion, ExportAll, ExportDecl, ExportDefaultDecl, ExportSpecifier, FnDecl, ForInStmt, - ForOfStmt, ForStmt, IfStmt, ImportDecl, ImportSpecifier, NamedExport, Param, Pat, Program, - Stmt, TsAsExpr, TsConstAssertion, TsEnumDecl, TsExportAssignment, TsImportEqualsDecl, - TsIndexSignature, TsInstantiation, TsModuleDecl, TsModuleName, TsNamespaceDecl, TsNonNullExpr, - TsParamPropParam, TsSatisfiesExpr, TsTypeAliasDecl, TsTypeAnn, TsTypeAssertion, - TsTypeParamDecl, TsTypeParamInstantiation, WhileStmt, + ArrowExpr, AutoAccessor, BindingIdent, Class, ClassDecl, ClassMethod, ClassProp, Constructor, + Decl, DoWhileStmt, EsVersion, ExportAll, ExportDecl, ExportDefaultDecl, ExportSpecifier, + FnDecl, ForInStmt, ForOfStmt, ForStmt, IfStmt, ImportDecl, ImportSpecifier, NamedExport, Param, + Pat, PrivateMethod, PrivateProp, Program, Stmt, TsAsExpr, TsConstAssertion, TsEnumDecl, + TsExportAssignment, TsImportEqualsDecl, TsIndexSignature, TsInstantiation, TsModuleDecl, + TsModuleName, TsNamespaceDecl, TsNonNullExpr, TsParamPropParam, TsSatisfiesExpr, + TsTypeAliasDecl, TsTypeAnn, TsTypeAssertion, TsTypeParamDecl, TsTypeParamInstantiation, + WhileStmt, }; use swc_ecma_parser::{ lexer::Lexer, @@ -441,6 +442,59 @@ impl TsStrip { self.add_overwrite(span.lo, b';'); } } + + fn strip_class_modifier(&mut self, mut start_pos: BytePos, key_pos: BytePos) { + let mut index = self.get_next_token_index(start_pos); + + while start_pos < key_pos { + let TokenAndSpan { token, span, .. } = &self.tokens[index]; + start_pos = span.hi; + index += 1; + + let next = &self.tokens[index]; + + if next.had_line_break { + return; + } + + // see ts_next_token_can_follow_modifier + // class { public public() {} } + if !matches!( + next.token, + Token::LBracket + | Token::LBrace + | Token::BinOp(BinOpToken::Mul) + | Token::DotDotDot + | Token::Hash + | Token::Word(_) + | Token::Str { .. } + | Token::Num { .. } + | Token::BigInt { .. } + ) { + return; + } + + match token { + Token::Word(Word::Ident(IdentLike::Known(KnownIdent::Static))) => { + continue; + } + Token::Word(Word::Ident(IdentLike::Known( + KnownIdent::Readonly + | KnownIdent::Public + | KnownIdent::Protected + | KnownIdent::Private, + ))) => { + self.add_replacement(*span); + } + Token::Word(Word::Ident(IdentLike::Other(o))) if *o == "override" => { + self.add_replacement(*span); + } + _ => { + return; + } + } + } + } } impl Visit for TsStrip { @@ -532,32 +586,31 @@ impl Visit for TsStrip { n.visit_children_with(self); } + fn visit_constructor(&mut self, n: &Constructor) { + if n.body.is_none() { + self.add_replacement(n.span); + return; + } + + self.strip_class_modifier(n.span_lo(), n.key.span_lo()); + + n.visit_children_with(self); + } + fn visit_class_method(&mut self, n: &ClassMethod) { if n.function.body.is_none() || n.is_abstract { self.add_replacement(n.span); return; } - let key_pos = n.key.span_lo(); - let mut pos = n.span_lo(); - let mut index = self.get_next_token_index(pos); + // @foo public m(): void {} + let start_pos = n + .function + .decorators + .last() + .map_or(n.span_lo(), |d| d.span_hi()); - while pos < key_pos { - let TokenAndSpan { token, span, .. } = &self.tokens[index]; - pos = span.hi; - index += 1; - match token { - Token::Word(Word::Ident(IdentLike::Known( - KnownIdent::Public | KnownIdent::Protected | KnownIdent::Private, - ))) => { - self.add_replacement(*span); - } - Token::Word(Word::Ident(IdentLike::Other(o))) if *o == "override" => { - self.add_replacement(*span); - } - _ => {} - } - } + self.strip_class_modifier(start_pos, n.key.span_lo()); n.visit_children_with(self); } @@ -568,29 +621,9 @@ impl Visit for TsStrip { return; } - let key_pos = n.key.span_lo(); - let mut pos = n.span_lo(); - let mut index = self.get_next_token_index(pos); + let start_pos = n.decorators.last().map_or(n.span_lo(), |d| d.span_hi()); - while pos < key_pos { - let TokenAndSpan { token, span, .. } = &self.tokens[index]; - pos = span.hi; - index += 1; - match token { - Token::Word(Word::Ident(IdentLike::Known( - KnownIdent::Readonly - | KnownIdent::Public - | KnownIdent::Protected - | KnownIdent::Private, - ))) => { - self.add_replacement(*span); - } - Token::Word(Word::Ident(IdentLike::Other(o))) if *o == "override" => { - self.add_replacement(*span); - } - _ => {} - } - } + self.strip_class_modifier(start_pos, n.key.span_lo()); if n.is_optional { let optional_mark = self.get_next_token(n.key.span_hi()); @@ -615,6 +648,39 @@ impl Visit for TsStrip { n.visit_children_with(self); } + fn visit_private_method(&mut self, n: &PrivateMethod) { + let start_pos = n + .function + .decorators + .last() + .map_or(n.span_lo(), |d| d.span_hi()); + + self.strip_class_modifier(start_pos, n.key.span_lo()); + + n.visit_children_with(self); + } + + fn visit_private_prop(&mut self, n: &PrivateProp) { + let start_pos = n.decorators.last().map_or(n.span_lo(), |d| d.span_hi()); + + self.strip_class_modifier(start_pos, n.key.span_lo()); + + n.visit_children_with(self); + } + + fn visit_auto_accessor(&mut self, n: &AutoAccessor) { + if n.is_abstract { + self.add_replacement(n.span); + return; + } + + let start_pos = n.decorators.last().map_or(n.span_lo(), |d| d.span_hi()); + + self.strip_class_modifier(start_pos, n.key.span_lo()); + + n.visit_children_with(self); + } + fn visit_export_all(&mut self, n: &ExportAll) { if n.type_only { self.add_replacement(n.span); diff --git a/crates/swc_fast_ts_strip/tests/tsc/Protected3.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/Protected3.strip.broken deleted file mode 100644 index a747a5493e85..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/Protected3.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - 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 | } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/Protected3.strip.js b/crates/swc_fast_ts_strip/tests/tsc/Protected3.strip.js deleted file mode 100644 index 9b98189f8444..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/Protected3.strip.js +++ /dev/null @@ -1,3 +0,0 @@ -class C { - protected constructor() { } -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/accessorsOverrideProperty9.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/accessorsOverrideProperty9.strip.broken deleted file mode 100644 index 7095c276efd8..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/accessorsOverrideProperty9.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - 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); - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/accessorsOverrideProperty9.strip.js b/crates/swc_fast_ts_strip/tests/tsc/accessorsOverrideProperty9.strip.js deleted file mode 100644 index 9e7d3e6c3035..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/accessorsOverrideProperty9.strip.js +++ /dev/null @@ -1,49 +0,0 @@ -// @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 []; - } -} diff --git a/crates/swc_fast_ts_strip/tests/tsc/autoAccessor7.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/autoAccessor7.strip.broken deleted file mode 100644 index fccfdbbcfbeb..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/autoAccessor7.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - 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 | } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/autoAccessor7.strip.js b/crates/swc_fast_ts_strip/tests/tsc/autoAccessor7.strip.js deleted file mode 100644 index fa2c6ee4f4cc..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/autoAccessor7.strip.js +++ /dev/null @@ -1,14 +0,0 @@ -// @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; } -} diff --git a/crates/swc_fast_ts_strip/tests/tsc/autoAccessorAllowedModifiers.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/autoAccessorAllowedModifiers.strip.broken index 43cd89fbea91..032870a3c1b3 100644 --- a/crates/swc_fast_ts_strip/tests/tsc/autoAccessorAllowedModifiers.strip.broken +++ b/crates/swc_fast_ts_strip/tests/tsc/autoAccessorAllowedModifiers.strip.broken @@ -1,7 +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 ; - `---- + x Unexpected token `!`. Expected * for generator, private key, identifier or async + ,-[$DIR/tests/tsc/autoAccessorAllowedModifiers.strip.js:18:1] + 17 | accessor ["m"] ; + 18 | accessor n! ; + : ^ + 19 | } + `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/autoAccessorAllowedModifiers.strip.js b/crates/swc_fast_ts_strip/tests/tsc/autoAccessorAllowedModifiers.strip.js index 986aeb76274f..219849404ef0 100644 --- a/crates/swc_fast_ts_strip/tests/tsc/autoAccessorAllowedModifiers.strip.js +++ b/crates/swc_fast_ts_strip/tests/tsc/autoAccessorAllowedModifiers.strip.js @@ -3,14 +3,14 @@ class C1 { accessor a ; - public accessor b ; - private accessor c ; - protected accessor d ; - abstract accessor e ; + accessor b ; + accessor c ; + accessor d ; + static accessor f ; - public static accessor g ; - private static accessor h ; - protected static accessor i ; + static accessor g ; + static accessor h ; + static accessor i ; accessor #j ; accessor "k" ; accessor 108 ; @@ -19,8 +19,8 @@ } class C2 extends C1 { - override accessor e ; - static override accessor i ; + accessor e ; + static accessor i ; } diff --git a/crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility4.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility4.strip.broken deleted file mode 100644 index feab6c0ea736..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility4.strip.broken +++ /dev/null @@ -1,6 +0,0 @@ - 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() { } - : ^^^^^^^^^^^ - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility4.strip.js b/crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility4.strip.js deleted file mode 100644 index 36c2cca11ac4..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility4.strip.js +++ /dev/null @@ -1,31 +0,0 @@ -// @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 - } - } -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility5.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility5.strip.broken deleted file mode 100644 index 704fb9efa373..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility5.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - 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 | } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility5.strip.js b/crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility5.strip.js deleted file mode 100644 index edbeedaaee0d..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/classConstructorAccessibility5.strip.js +++ /dev/null @@ -1,10 +0,0 @@ -class Base { - protected constructor() { } -} -class Derived extends Base { - static make() { new Base() } // ok -} - -class Unrelated { - static fake() { new Base() } // error -} diff --git a/crates/swc_fast_ts_strip/tests/tsc/classConstructorOverloadsAccessibility.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/classConstructorOverloadsAccessibility.strip.broken deleted file mode 100644 index ba2ed4f62b1a..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/classConstructorOverloadsAccessibility.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - 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 - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/classConstructorOverloadsAccessibility.strip.js b/crates/swc_fast_ts_strip/tests/tsc/classConstructorOverloadsAccessibility.strip.js deleted file mode 100644 index 2cfca3790bb2..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/classConstructorOverloadsAccessibility.strip.js +++ /dev/null @@ -1,34 +0,0 @@ -// @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() { - - } -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/constructSignaturesWithIdenticalOverloads.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/constructSignaturesWithIdenticalOverloads.strip.broken deleted file mode 100644 index 19941f6d0305..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/constructSignaturesWithIdenticalOverloads.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/constructSignaturesWithIdenticalOverloads.strip.js:4:1] - 3 | class C { - 4 | constructor(x , y ); - : ^ - 5 | constructor(x , y ); // error - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/constructSignaturesWithIdenticalOverloads.strip.js b/crates/swc_fast_ts_strip/tests/tsc/constructSignaturesWithIdenticalOverloads.strip.js deleted file mode 100644 index 0c028134205a..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/constructSignaturesWithIdenticalOverloads.strip.js +++ /dev/null @@ -1,49 +0,0 @@ -// Duplicate overloads of construct signatures should generate errors - -class C { - constructor(x , y ); - constructor(x , y ); // error - constructor(x ) { } -} - -var r1 = new C(1, ''); - -class C2 { - constructor(x , y ); - constructor(x , y ); // error - constructor(x ) { } -} - -var r2 = new C2(1, ''); - - - - - - -var i ; -var r3 = new i(1, ''); - - - - - - - - -var i2 ; -var r4 = new i2(1, ''); - -var a - - - - -var r5 = new a(1, ''); - -var b - - - - -var r6 = new b(1, ''); \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/constructSignaturesWithOverloads.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/constructSignaturesWithOverloads.strip.broken deleted file mode 100644 index 7cc406c9d2ff..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/constructSignaturesWithOverloads.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/constructSignaturesWithOverloads.strip.js:4:1] - 3 | class C { - 4 | constructor(x , y ); - : ^ - 5 | constructor(x , y ); - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/constructSignaturesWithOverloads.strip.js b/crates/swc_fast_ts_strip/tests/tsc/constructSignaturesWithOverloads.strip.js deleted file mode 100644 index 954707aa9016..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/constructSignaturesWithOverloads.strip.js +++ /dev/null @@ -1,50 +0,0 @@ -// No errors expected for basic overloads of construct signatures - -class C { - constructor(x , y ); - constructor(x , y ); - constructor(x ) { } -} - -var r1 = new C(1, ''); - -class C2 { - constructor(x , y ); - constructor(x , y ); - constructor(x ) { } -} - -var r2 = new C2(1, ''); - - - - - - -var i ; -var r3 = new i(1, ''); - - - - - - - - - -var i2 ; -var r4 = new i2(1, ''); - -var a - - - - -var r5 = new a(1, ''); - -var b - - - - -var r6 = new b(1, ''); \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/constructorImplementationWithDefaultValues.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/constructorImplementationWithDefaultValues.strip.broken deleted file mode 100644 index e832586d87a8..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/constructorImplementationWithDefaultValues.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/constructorImplementationWithDefaultValues.strip.js:2:1] - 1 | class C { - 2 | constructor(x); - : ^ - 3 | constructor(x = 1) { - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/constructorImplementationWithDefaultValues.strip.js b/crates/swc_fast_ts_strip/tests/tsc/constructorImplementationWithDefaultValues.strip.js deleted file mode 100644 index b41b9c5d8d0a..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/constructorImplementationWithDefaultValues.strip.js +++ /dev/null @@ -1,20 +0,0 @@ -class C { - constructor(x); - constructor(x = 1) { - var y = x; - } -} - -class D { - constructor(x); - constructor(x = null) { - var y = x; - } -} - -class E { - constructor(x); - constructor(x = null) { - var y = x; - } -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/constructorOverloadsWithOptionalParameters.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/constructorOverloadsWithOptionalParameters.strip.broken deleted file mode 100644 index 43692f4dba03..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/constructorOverloadsWithOptionalParameters.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/constructorOverloadsWithOptionalParameters.strip.js:3:1] - 2 | foo ; - 3 | constructor(x , y ); - : ^ - 4 | constructor() { - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/constructorOverloadsWithOptionalParameters.strip.js b/crates/swc_fast_ts_strip/tests/tsc/constructorOverloadsWithOptionalParameters.strip.js deleted file mode 100644 index d58a94f9c83d..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/constructorOverloadsWithOptionalParameters.strip.js +++ /dev/null @@ -1,13 +0,0 @@ -class C { - foo ; - constructor(x , y ); - constructor() { - } -} - -class D { - foo ; - constructor(x , y ); - constructor() { - } -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/derivedClassWithoutExplicitConstructor2.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/derivedClassWithoutExplicitConstructor2.strip.broken deleted file mode 100644 index 623bf039fc71..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/derivedClassWithoutExplicitConstructor2.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/derivedClassWithoutExplicitConstructor2.strip.js:3:1] - 2 | a = 1; - 3 | constructor(x , y , z ); - : ^ - 4 | constructor(x , y ); - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/derivedClassWithoutExplicitConstructor2.strip.js b/crates/swc_fast_ts_strip/tests/tsc/derivedClassWithoutExplicitConstructor2.strip.js deleted file mode 100644 index bc18361e6c8d..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/derivedClassWithoutExplicitConstructor2.strip.js +++ /dev/null @@ -1,33 +0,0 @@ -class Base { - a = 1; - constructor(x , y , z ); - constructor(x , y ); - constructor(x ) { this.a = x; } -} - -class Derived extends Base { - x = 1 - y = 'hello'; -} - -var r = new Derived(); // error -var r2 = new Derived(1); -var r3 = new Derived(1, 2); -var r4 = new Derived(1, 2, 3); - -class Base2 { - a ; - constructor(x , y , z ); - constructor(x , y ); - constructor(x ) { this.a = x; } -} - -class D extends Base2 { - x = 2 - y = null; -} - -var d = new D(); // error -var d2 = new D(new Date()); // ok -var d3 = new D(new Date(), new Date()); -var d4 = new D(new Date(), new Date(), new Date()); \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationOverloadInES6.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationOverloadInES6.strip.broken deleted file mode 100644 index c35c13af59d5..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationOverloadInES6.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got 'constructor' - ,-[$DIR/tests/tsc/emitClassDeclarationOverloadInES6.strip.js:4:1] - 3 | constructor(y ) - 4 | constructor(x ) { - : ^^^^^^^^^^^ - 5 | } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationOverloadInES6.strip.js b/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationOverloadInES6.strip.js deleted file mode 100644 index 3dba9908d662..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationOverloadInES6.strip.js +++ /dev/null @@ -1,11 +0,0 @@ -// @target: es6 -class C { - constructor(y ) - constructor(x ) { - } -} - -class D { - constructor(y ) - constructor(x , z="hello") {} -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationWithExtensionAndTypeArgumentInES6.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationWithExtensionAndTypeArgumentInES6.strip.broken deleted file mode 100644 index db1cf5d932cb..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationWithExtensionAndTypeArgumentInES6.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got 'constructor' - ,-[$DIR/tests/tsc/emitClassDeclarationWithExtensionAndTypeArgumentInES6.strip.js:8:1] - 7 | constructor(a ) - 8 | constructor(b ) { - : ^^^^^^^^^^^ - 9 | super(b); - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationWithExtensionAndTypeArgumentInES6.strip.js b/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationWithExtensionAndTypeArgumentInES6.strip.js deleted file mode 100644 index ba8e616a6f3a..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationWithExtensionAndTypeArgumentInES6.strip.js +++ /dev/null @@ -1,11 +0,0 @@ -// @target: es6 -class B { - constructor(a ) { } -} -class C extends B { } -class D extends B { - constructor(a ) - constructor(b ) { - super(b); - } -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationWithTypeArgumentAndOverloadInES6.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationWithTypeArgumentAndOverloadInES6.strip.broken deleted file mode 100644 index 9d60778e4a77..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationWithTypeArgumentAndOverloadInES6.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got 'constructor' - ,-[$DIR/tests/tsc/emitClassDeclarationWithTypeArgumentAndOverloadInES6.strip.js:7:1] - 6 | constructor(a ) - 7 | constructor(a ,b ) - : ^^^^^^^^^^^ - 8 | constructor(a ) { this.B = a;} - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationWithTypeArgumentAndOverloadInES6.strip.js b/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationWithTypeArgumentAndOverloadInES6.strip.js deleted file mode 100644 index 0ceac7b0255f..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/emitClassDeclarationWithTypeArgumentAndOverloadInES6.strip.js +++ /dev/null @@ -1,23 +0,0 @@ -// @target: es6 -class B { - x ; - B ; - - constructor(a ) - constructor(a ,b ) - constructor(a ) { this.B = a;} - - - - - foo() { - return this.x; - } - - get BB() { - return this.B; - } - set BBWith(c ) { - this.B = c; - } -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/esDecorators-classDeclaration-classSuper.7.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/esDecorators-classDeclaration-classSuper.7.strip.broken deleted file mode 100644 index 771ba19468d4..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/esDecorators-classDeclaration-classSuper.7.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Unexpected token `constructor`. Expected * for generator, private key, identifier or async - ,-[$DIR/tests/tsc/esDecorators-classDeclaration-classSuper.7.strip.js:7:1] - 6 | class B extends A { - 7 | public constructor() { - : ^^^^^^^^^^^ - 8 | 'inject'; - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/esDecorators-classDeclaration-classSuper.7.strip.js b/crates/swc_fast_ts_strip/tests/tsc/esDecorators-classDeclaration-classSuper.7.strip.js deleted file mode 100644 index 61376dbcabad..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/esDecorators-classDeclaration-classSuper.7.strip.js +++ /dev/null @@ -1,43 +0,0 @@ -// @target: es2022 -// @noEmitHelpers: true -// @noTypesAndSymbols: true - -class A {} -class B extends A { - public constructor() { - 'inject'; - super(); - const a = 1; - const b = 1; - } - - @foo - m() {} -} - -function foo(method , _context ) { - return function ( ) { - method.call(this); - }; -} - -new B(); - -// https://github.com/microsoft/TypeScript/issues/53448 -class C { - public constructor() { - this.val; - } - - @foo - get val() { return 3; } -} -class D extends A { - public constructor() { - super(); - this.val; - } - - @foo - get val() { return 3; } -} diff --git a/crates/swc_fast_ts_strip/tests/tsc/functionLiteralForOverloads2.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/functionLiteralForOverloads2.strip.broken deleted file mode 100644 index 1f2f1f08a635..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/functionLiteralForOverloads2.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/functionLiteralForOverloads2.strip.js:4:1] - 3 | class C { - 4 | constructor(x ); - : ^ - 5 | constructor(x ); - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/functionLiteralForOverloads2.strip.js b/crates/swc_fast_ts_strip/tests/tsc/functionLiteralForOverloads2.strip.js deleted file mode 100644 index 8ae0895270bb..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/functionLiteralForOverloads2.strip.js +++ /dev/null @@ -1,28 +0,0 @@ -// basic uses of function literals with constructor overloads - -class C { - constructor(x ); - constructor(x ); - constructor(x) { } -} - -class D { - constructor(x ); - constructor(x ); - constructor(x) { } -} - -var f - - - = C; - -var f2 - - - = C; - -var f3 - - - = D; \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/overloadResolutionClassConstructors.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/overloadResolutionClassConstructors.strip.broken deleted file mode 100644 index 445c30f0cf76..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/overloadResolutionClassConstructors.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/overloadResolutionClassConstructors.strip.js:19:1] - 18 | class fn1 { - 19 | constructor(s ); - : ^ - 20 | constructor(s ); - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/overloadResolutionClassConstructors.strip.js b/crates/swc_fast_ts_strip/tests/tsc/overloadResolutionClassConstructors.strip.js deleted file mode 100644 index dc2799860643..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/overloadResolutionClassConstructors.strip.js +++ /dev/null @@ -1,100 +0,0 @@ -class SomeBase { - n; - - s ; -} -class SomeDerived1 extends SomeBase { - m; -} -class SomeDerived2 extends SomeBase { - m; -} -class SomeDerived3 extends SomeBase { - m; -} - - -// Ambiguous call picks the first overload in declaration order -class fn1 { - constructor(s ); - constructor(s ); - constructor() { } -} - -new fn1(undefined); - -// No candidate overloads found -new fn1({}); // Error - -// Generic and non - generic overload where generic overload is the only candidate when called with type arguments -class fn2 { - constructor(s , n ); - constructor(n , t ); - constructor() { } -} - -var d = new fn2 (0, undefined); - -// Generic and non - generic overload where generic overload is the only candidate when called without type arguments -var s = new fn2(0, ''); - -// Generic and non - generic overload where non - generic overload is the only candidate when called with type arguments -new fn2 ('', 0); // OK - -// Generic and non - generic overload where non - generic overload is the only candidate when called without type arguments -new fn2('', 0); // OK - -// Generic overloads with differing arity called without type arguments -class fn3 { - constructor(n ); - constructor(s , t , u ); - constructor(v , u , t ); - constructor() { } -} - -new fn3(3); -new fn3('', 3, ''); -new fn3(5, 5, 5); - -// Generic overloads with differing arity called with type arguments matching each overload type parameter count -new fn3 (4); // Error -new fn3 ('', '', ''); // Error -new fn3 ('', '', 3); - -// Generic overloads with differing arity called with type argument count that doesn't match any overload -new fn3 (); // Error - -// Generic overloads with constraints called with type arguments that satisfy the constraints -class fn4 { - constructor(n , m ); - constructor() { } -} -new fn4 ('', 3); -new fn4 (3, ''); // Error -new fn4 ('', 3); // Error -new fn4 (3, ''); // Error - -// Generic overloads with constraints called without type arguments but with types that satisfy the constraints -new fn4('', 3); -new fn4(3, ''); // Error -new fn4(3, undefined); // Error -new fn4('', null); - -// Generic overloads with constraints called with type arguments that do not satisfy the constraints -new fn4 (null, null); // Error - -// Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints -new fn4(true, null); // Error -new fn4(null, true); // Error - -// Non - generic overloads where contextual typing of function arguments has errors -class fn5 { - constructor(f ); - constructor(f ); - constructor() { return undefined; } -} -new fn5((n) => n.toFixed()); -new fn5((n) => n.substr(0)); -new fn5((n) => n.blah); // Error - - diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration10.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration10.strip.broken deleted file mode 100644 index 5af97c9464ec..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration10.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/parserClassDeclaration10.strip.js:2:1] - 1 | class C { - 2 | constructor(); - : ^ - 3 | - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration10.strip.js b/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration10.strip.js deleted file mode 100644 index 24d2f7b8846c..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration10.strip.js +++ /dev/null @@ -1,4 +0,0 @@ -class C { - constructor(); - -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration11.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration11.strip.broken deleted file mode 100644 index ebb657111087..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration11.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/parserClassDeclaration11.strip.js:2:1] - 1 | class C { - 2 | constructor(); - : ^ - 3 | foo() { } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration11.strip.js b/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration11.strip.js deleted file mode 100644 index fa3d96a4d4b3..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration11.strip.js +++ /dev/null @@ -1,4 +0,0 @@ -class C { - constructor(); - foo() { } -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration12.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration12.strip.broken deleted file mode 100644 index 65363bfea1b8..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration12.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/parserClassDeclaration12.strip.js:2:1] - 1 | class C { - 2 | constructor(); - : ^ - 3 | constructor(a) { } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration12.strip.js b/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration12.strip.js deleted file mode 100644 index c42f1d8345c1..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration12.strip.js +++ /dev/null @@ -1,4 +0,0 @@ -class C { - constructor(); - constructor(a) { } -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration14.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration14.strip.broken deleted file mode 100644 index b24be48005b1..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration14.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/parserClassDeclaration14.strip.js:3:1] - 2 | - 3 | constructor(); - : ^ - 4 | } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration14.strip.js b/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration14.strip.js deleted file mode 100644 index c34cc76024d6..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration14.strip.js +++ /dev/null @@ -1,4 +0,0 @@ -class C { - - constructor(); -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration8.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration8.strip.broken deleted file mode 100644 index 6175dc82715c..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration8.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/parserClassDeclaration8.strip.js:2:1] - 1 | class C { - 2 | constructor(); - : ^ - 3 | } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration8.strip.js b/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration8.strip.js deleted file mode 100644 index 68a91120c59c..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserClassDeclaration8.strip.js +++ /dev/null @@ -1,3 +0,0 @@ -class C { - constructor(); -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserConstructorDeclaration1.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/parserConstructorDeclaration1.strip.broken deleted file mode 100644 index 81f191df2582..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserConstructorDeclaration1.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Unexpected token `constructor`. Expected * for generator, private key, identifier or async - ,-[$DIR/tests/tsc/parserConstructorDeclaration1.strip.js:2:1] - 1 | class C { - 2 | public constructor() { } - : ^^^^^^^^^^^ - 3 | } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserConstructorDeclaration1.strip.js b/crates/swc_fast_ts_strip/tests/tsc/parserConstructorDeclaration1.strip.js deleted file mode 100644 index 7eec39f4b251..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserConstructorDeclaration1.strip.js +++ /dev/null @@ -1,3 +0,0 @@ -class C { - public constructor() { } -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserConstructorDeclaration5.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/parserConstructorDeclaration5.strip.broken deleted file mode 100644 index 3cedee26bc4f..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserConstructorDeclaration5.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Unexpected token `constructor`. Expected * for generator, private key, identifier or async - ,-[$DIR/tests/tsc/parserConstructorDeclaration5.strip.js:2:1] - 1 | class C { - 2 | private constructor() { } - : ^^^^^^^^^^^ - 3 | } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserConstructorDeclaration5.strip.js b/crates/swc_fast_ts_strip/tests/tsc/parserConstructorDeclaration5.strip.js deleted file mode 100644 index 688a04bfcc57..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserConstructorDeclaration5.strip.js +++ /dev/null @@ -1,3 +0,0 @@ -class C { - private constructor() { } -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserMemberFunctionDeclarationAmbiguities1.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/parserMemberFunctionDeclarationAmbiguities1.strip.broken deleted file mode 100644 index 06ea3cbaf776..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserMemberFunctionDeclarationAmbiguities1.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Unexpected token `(`. Expected identifier, string literal, numeric literal or [ for the computed key - ,-[$DIR/tests/tsc/parserMemberFunctionDeclarationAmbiguities1.strip.js:5:1] - 4 | - 5 | () {} - : ^ - 6 | static() {} - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/parserMemberFunctionDeclarationAmbiguities1.strip.js b/crates/swc_fast_ts_strip/tests/tsc/parserMemberFunctionDeclarationAmbiguities1.strip.js deleted file mode 100644 index 90c54fe5954a..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/parserMemberFunctionDeclarationAmbiguities1.strip.js +++ /dev/null @@ -1,13 +0,0 @@ -class C { - public() {} - static() {} - - () {} - static() {} - - static () {} - static static() {} - - static () {} - static static() {} -} \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/privateNameComputedPropertyName1.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/privateNameComputedPropertyName1.strip.broken deleted file mode 100644 index e17291f61da4..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/privateNameComputedPropertyName1.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Unexpected token `#`. Expected * for generator, private key, identifier or async - ,-[$DIR/tests/tsc/privateNameComputedPropertyName1.strip.js:7:1] - 6 | - 7 | readonly #c = 'c'; - : ^ - 8 | readonly #d ; - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/privateNameComputedPropertyName1.strip.js b/crates/swc_fast_ts_strip/tests/tsc/privateNameComputedPropertyName1.strip.js deleted file mode 100644 index 095765698a82..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/privateNameComputedPropertyName1.strip.js +++ /dev/null @@ -1,38 +0,0 @@ -// @target: esnext, es2022, es2015 - -class A { - #a = 'a'; - #b ; - - readonly #c = 'c'; - readonly #d ; - - #e = ''; - - constructor() { - this.#b = 'b'; - this.#d = 'd'; - } - - test() { - const data = { a: 'a', b: 'b', c: 'c', d: 'd', e: 'e' }; - const { - [this.#a]: a, - [this.#b]: b, - [this.#c]: c, - [this.#d]: d, - [this.#e = 'e']: e, - } = data; - console.log(a, b, c, d, e); - - const a1 = data[this.#a]; - const b1 = data[this.#b]; - const c1 = data[this.#c]; - const d1 = data[this.#d]; - const e1 = data[this.#e]; - console.log(a1, b1, c1, d1); - } -} - -new A().test(); - diff --git a/crates/swc_fast_ts_strip/tests/tsc/typeofClass2.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/typeofClass2.strip.broken deleted file mode 100644 index d064f4db1546..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/typeofClass2.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/typeofClass2.strip.js:2:1] - 1 | class C { - 2 | constructor(x ); - : ^ - 3 | constructor(x ); - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/typeofClass2.strip.js b/crates/swc_fast_ts_strip/tests/tsc/typeofClass2.strip.js deleted file mode 100644 index f16381678157..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/typeofClass2.strip.js +++ /dev/null @@ -1,21 +0,0 @@ -class C { - constructor(x ); - constructor(x ); - constructor(x) { } - - - - static foo(x) { } - - static bar(x) { } -} - -class D extends C { - static baz(x ) { } - foo() { } -} - -var d ; - -var r1 ; -var r2 ; \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/typesWithPrivateConstructor.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/typesWithPrivateConstructor.strip.broken deleted file mode 100644 index 76b863636d63..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/typesWithPrivateConstructor.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Unexpected token `constructor`. Expected * for generator, private key, identifier or async - ,-[$DIR/tests/tsc/typesWithPrivateConstructor.strip.js:4:1] - 3 | class C { - 4 | private constructor() { } - : ^^^^^^^^^^^ - 5 | } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/typesWithPrivateConstructor.strip.js b/crates/swc_fast_ts_strip/tests/tsc/typesWithPrivateConstructor.strip.js deleted file mode 100644 index 6ff1f4da4f8b..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/typesWithPrivateConstructor.strip.js +++ /dev/null @@ -1,16 +0,0 @@ -// @declaration: true - -class C { - private constructor() { } -} - -var c = new C(); // error C is private -var r = c.constructor; - -class C2 { - private constructor(x ); - private constructor(x ) { } -} - -var c2 = new C2(); // error C2 is private -var r2 = c2.constructor; \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/typesWithProtectedConstructor.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/typesWithProtectedConstructor.strip.broken deleted file mode 100644 index 6cfea87f8c24..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/typesWithProtectedConstructor.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Unexpected token `constructor`. Expected * for generator, private key, identifier or async - ,-[$DIR/tests/tsc/typesWithProtectedConstructor.strip.js:4:1] - 3 | class C { - 4 | protected constructor() { } - : ^^^^^^^^^^^ - 5 | } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/typesWithProtectedConstructor.strip.js b/crates/swc_fast_ts_strip/tests/tsc/typesWithProtectedConstructor.strip.js deleted file mode 100644 index 64c48415990e..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/typesWithProtectedConstructor.strip.js +++ /dev/null @@ -1,16 +0,0 @@ -// @declaration: true - -class C { - protected constructor() { } -} - -var c = new C(); // error C is protected -var r = c.constructor; - -class C2 { - protected constructor(x ); - protected constructor(x ) { } -} - -var c2 = new C2(); // error C2 is protected -var r2 = c2.constructor; \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/typesWithPublicConstructor.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/typesWithPublicConstructor.strip.broken deleted file mode 100644 index 8b3dcccf97f8..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/typesWithPublicConstructor.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Unexpected token `constructor`. Expected * for generator, private key, identifier or async - ,-[$DIR/tests/tsc/typesWithPublicConstructor.strip.js:4:1] - 3 | class C { - 4 | public constructor() { } - : ^^^^^^^^^^^ - 5 | } - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/typesWithPublicConstructor.strip.js b/crates/swc_fast_ts_strip/tests/tsc/typesWithPublicConstructor.strip.js deleted file mode 100644 index d7ef0cbbbc3d..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/typesWithPublicConstructor.strip.js +++ /dev/null @@ -1,16 +0,0 @@ -// public is allowed on a constructor but is not meaningful - -class C { - public constructor() { } -} - -var c = new C(); -var r = c.constructor; - -class C2 { - public constructor(x ); - public constructor(x ) { } -} - -var c2 = new C2(); -var r2 = c2.constructor; \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/typesWithSpecializedConstructSignatures.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/typesWithSpecializedConstructSignatures.strip.broken deleted file mode 100644 index 6ff712bb23e7..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/typesWithSpecializedConstructSignatures.strip.broken +++ /dev/null @@ -1,7 +0,0 @@ - x Expected '{', got ';' - ,-[$DIR/tests/tsc/typesWithSpecializedConstructSignatures.strip.js:8:1] - 7 | class C { - 8 | constructor(x ); - : ^ - 9 | constructor(x ); - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/typesWithSpecializedConstructSignatures.strip.js b/crates/swc_fast_ts_strip/tests/tsc/typesWithSpecializedConstructSignatures.strip.js deleted file mode 100644 index d42fae8c29f4..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/typesWithSpecializedConstructSignatures.strip.js +++ /dev/null @@ -1,39 +0,0 @@ -// basic uses of specialized signatures without errors - -class Base { foo } -class Derived1 extends Base { bar } -class Derived2 extends Base { baz } - -class C { - constructor(x ); - constructor(x ); - constructor(x ); - constructor(x) { - return x; - } -} -var c = new C('a'); - - - - - - -var i ; - -var a - - - - ; - -c = i; -c = a; - -i = a; - -a = i; - -var r1 = new C('hi'); -var r2 = new i('bye'); -var r3 = new a('hm'); \ No newline at end of file diff --git a/crates/swc_fast_ts_strip/tests/tsc/varRequireFromTypescript.strip.broken b/crates/swc_fast_ts_strip/tests/tsc/varRequireFromTypescript.strip.broken deleted file mode 100644 index 6af9a3ff0099..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/varRequireFromTypescript.strip.broken +++ /dev/null @@ -1,6 +0,0 @@ - x Expected '{', got '}' - ,-[$DIR/tests/tsc/varRequireFromTypescript.strip.js:11:1] - 10 | constructor(n ) - 11 | } - : ^ - `---- diff --git a/crates/swc_fast_ts_strip/tests/tsc/varRequireFromTypescript.strip.js b/crates/swc_fast_ts_strip/tests/tsc/varRequireFromTypescript.strip.js deleted file mode 100644 index 2a552a8f82da..000000000000 --- a/crates/swc_fast_ts_strip/tests/tsc/varRequireFromTypescript.strip.js +++ /dev/null @@ -1,29 +0,0 @@ -// @allowJs: true -// @checkJs: true -// @strict: true -// @noEmit: true -// @Filename: ex.d.ts - -export class Crunch { - n - - constructor(n ) -} - -// @Filename: use.js -var ex = require('./ex') - -// values work -var crunch = new ex.Crunch(1); -crunch.n - - -// types work -/** - * @param {ex.Greatest} greatest - * @param {ex.Crunch} wrap - */ -function f(greatest, wrap) { - greatest.day - wrap.n -}