mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 02:06:08 +03:00
fix(es/transforms/strip): Strip types for typescript export equals (#2623)
swc_ecma_transforms_typescript: - `strip`: Visit the RHS of typescript export equals.
This commit is contained in:
parent
c89a9ea171
commit
d2f2409528
@ -2158,7 +2158,9 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
ModuleItem::ModuleDecl(ModuleDecl::TsExportAssignment(export)) => {
|
||||
ModuleItem::ModuleDecl(ModuleDecl::TsExportAssignment(mut export)) => {
|
||||
export.expr.visit_mut_with(self);
|
||||
|
||||
stmts.push(ModuleItem::Stmt(Stmt::Expr(ExprStmt {
|
||||
span: export.span,
|
||||
expr: Box::new(Expr::Assign(AssignExpr {
|
||||
|
@ -4176,6 +4176,20 @@ test_with_config!(
|
||||
"
|
||||
);
|
||||
|
||||
to!(
|
||||
issue_2613,
|
||||
"
|
||||
export = function (foo: string, bar: number): boolean {
|
||||
return true
|
||||
};
|
||||
",
|
||||
"
|
||||
module.exports = function (foo, bar) {
|
||||
return true
|
||||
};
|
||||
"
|
||||
);
|
||||
|
||||
#[testing::fixture("tests/fixture/**/input.ts")]
|
||||
#[testing::fixture("tests/fixture/**/input.tsx")]
|
||||
fn exec(input: PathBuf) {
|
||||
|
10
tests/fixture/issue-2613/1/input/.swcrc
Normal file
10
tests/fixture/issue-2613/1/input/.swcrc
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript"
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
}
|
||||
}
|
3
tests/fixture/issue-2613/1/input/index.ts
Normal file
3
tests/fixture/issue-2613/1/input/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export = function (foo: string, bar: number): boolean {
|
||||
return true
|
||||
}
|
7
tests/fixture/issue-2613/1/output/index.ts
Normal file
7
tests/fixture/issue-2613/1/output/index.ts
Normal file
@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
module.exports = function(foo, bar) {
|
||||
return true;
|
||||
};
|
Loading…
Reference in New Issue
Block a user