Skip to content

Commit 3c68159

Browse files
committed
feat: 去掉 typescript 声明
1 parent cec4e20 commit 3c68159

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ dist
121121
.AppleDouble
122122
.LSOverride
123123

124-
# Icon must end with two
124+
# Icon must end with two
125125
Icon
126126

127127

@@ -195,3 +195,5 @@ Cargo.lock
195195
!.yarn/versions
196196

197197
*.node
198+
199+
src/main.rs

src/document.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use swc_ecma_ast::{EsVersion, Program};
1010
use swc_ecma_parser::{lexer::Lexer, Parser, StringInput, Syntax, TsConfig};
1111
use swc_ecma_visit::{VisitWith, FoldWith};
1212
use swc_ecma_transforms_base::{fixer::fixer, hygiene::hygiene, resolver};
13+
use swc_ecmascript::transforms::typescript::strip;
1314

1415
use crate::{
1516
scraper::{ElementRef, Node, Selector},
@@ -63,6 +64,7 @@ impl JSXDocument {
6364
let unresolved_mark = Mark::new();
6465
let top_level_mark = Mark::new();
6566
let program = program.fold_with(&mut resolver(unresolved_mark, top_level_mark, true));
67+
let program = program.fold_with(&mut strip(top_level_mark));
6668
let program = program.fold_with(&mut hygiene());
6769
let program = program.fold_with(&mut fixer(Some(comments)));
6870
let mut jsx_record: JSXRecord = HashMap::new();

0 commit comments

Comments
 (0)