Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(es/visit): Visit TypeScript satisfies expressions #6511

Merged
merged 6 commits into from Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/swc_ecma_transforms_base/src/resolver/mod.rs
Expand Up @@ -1133,6 +1133,14 @@ impl<'a> VisitMut for Resolver<'a> {
n.expr.visit_mut_with(self);
}

fn visit_mut_ts_satisfies_expr(&mut self, n: &mut TsSatisfiesExpr) {
if self.config.handle_types {
n.type_ann.visit_mut_with(self);
}

n.expr.visit_mut_with(self);
}

fn visit_mut_ts_call_signature_decl(&mut self, n: &mut TsCallSignatureDecl) {
if !self.config.handle_types {
return;
Expand Down
@@ -0,0 +1,11 @@
type Movable = {
move(distance: number): void;
};

const car = {
start() { },
move(d) {
// d should be number
},
stop() { }
} satisfies Movable & Record<string, unknown>;
@@ -0,0 +1,8 @@
type Movable__1 = {
move__0(distance: number): void;
};
const car__1 = {
start () {},
move (d__3) {},
stop () {}
} satisfies Movable__1 & Record<string, unknown>;
@@ -0,0 +1,11 @@
type Movable = {
move(distance: number): void;
};

const car = {
start() { },
move(d) {
// d should be number
},
stop() { }
} as Movable & Record<string, unknown>;
@@ -0,0 +1,8 @@
type Movable__1 = {
move__0(distance: number): void;
};
const car__1 = {
start () {},
move (d__3) {},
stop () {}
} as Movable__1 & Record<string, unknown>;
6 changes: 6 additions & 0 deletions crates/swc_ecma_visit/src/lib.rs
Expand Up @@ -1816,6 +1816,12 @@ define!({
pub type_args: Box<TsTypeParamInstantiation>,
}

pub struct TsSatisfiesExpr {
pub span: Span,
pub expr: Box<Expr>,
pub type_ann: Box<TsType>,
}

pub struct ReservedUnused {
pub span: Span,
pub body: Option<Vec<ModuleItem>>,
Expand Down