From b0868784032629b07bc536cc7564c5b9da2c22a9 Mon Sep 17 00:00:00 2001 From: nissy-dev Date: Sat, 5 Nov 2022 16:27:38 +0900 Subject: [PATCH 1/5] fix: satisfies expressions are parsed as TsSatisfactionExpression --- crates/swc_ecma_parser/src/parser/expr/ops.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/swc_ecma_parser/src/parser/expr/ops.rs b/crates/swc_ecma_parser/src/parser/expr/ops.rs index 410c4dd063e0..149e8ac76dbd 100644 --- a/crates/swc_ecma_parser/src/parser/expr/ops.rs +++ b/crates/swc_ecma_parser/src/parser/expr/ops.rs @@ -122,7 +122,7 @@ impl Parser { let expr = left; let node = { let type_ann = self.next_then_parse_ts_type()?; - Box::new(Expr::TsAs(TsAsExpr { + Box::new(Expr::TsSatisfaction(TsSatisfactionExpr { span: span!(self, start), expr, type_ann, From aab042c02cace3c475d830119021e0273da4cfa7 Mon Sep 17 00:00:00 2001 From: nissy-dev Date: Sat, 5 Nov 2022 17:12:16 +0900 Subject: [PATCH 2/5] fix: update snapshot --- .../tests/tsc/typeSatisfaction.json | 16 ++++++++-------- .../tsc/typeSatisfaction_contextualTyping1.json | 2 +- .../typeSatisfaction_ensureInterfaceImpl.json | 2 +- .../tests/tsc/typeSatisfaction_js.json | 2 +- ...peSatisfaction_optionalMemberConformance.json | 2 +- .../typeSatisfaction_propNameConstraining.json | 2 +- ...typeSatisfaction_propertyNameFulfillment.json | 2 +- ...peSatisfaction_propertyValueConformance1.json | 2 +- ...peSatisfaction_propertyValueConformance2.json | 2 +- ...peSatisfaction_propertyValueConformance3.json | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction.json index 3c8bb6405c0b..49c05640ab4d 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction.json @@ -290,7 +290,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 110, "end": 131, @@ -382,7 +382,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 150, "end": 177, @@ -497,7 +497,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 199, "end": 215, @@ -591,7 +591,7 @@ } }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 242, "end": 265, @@ -683,7 +683,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 284, "end": 318, @@ -827,7 +827,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 338, "end": 371, @@ -1021,7 +1021,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 413, "end": 438, @@ -1113,7 +1113,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 449, "end": 485, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_contextualTyping1.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_contextualTyping1.json index 58597ce140a5..c226e93a13fe 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_contextualTyping1.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_contextualTyping1.json @@ -167,7 +167,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 71, "end": 153, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_ensureInterfaceImpl.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_ensureInterfaceImpl.json index b4e685055e13..36b337b9618d 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_ensureInterfaceImpl.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_ensureInterfaceImpl.json @@ -133,7 +133,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 68, "end": 198, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.json index f8cd9727208a..31463f839391 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.json @@ -35,7 +35,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 71, "end": 92, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_optionalMemberConformance.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_optionalMemberConformance.json index fea0e7675538..568b8745525b 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_optionalMemberConformance.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_optionalMemberConformance.json @@ -147,7 +147,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 103, "end": 139, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propNameConstraining.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propNameConstraining.json index a18fe3f1deae..e33e8145ca56 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propNameConstraining.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propNameConstraining.json @@ -137,7 +137,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 47, "end": 163, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyNameFulfillment.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyNameFulfillment.json index e9905c228860..f8f6227b4c79 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyNameFulfillment.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyNameFulfillment.json @@ -137,7 +137,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 47, "end": 154, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance1.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance1.json index 78d1eb87625f..292a2c39226b 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance1.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance1.json @@ -681,7 +681,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 476, "end": 523, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance2.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance2.json index 3643523c63c8..107557ec0fad 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance2.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance2.json @@ -681,7 +681,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 457, "end": 504, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance3.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance3.json index 09062330e612..091b20aab501 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance3.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance3.json @@ -203,7 +203,7 @@ "typeAnnotation": null }, "init": { - "type": "TsAsExpression", + "type": "TsSatisfactionExpr", "span": { "start": 150, "end": 323, From a489037ef4f5a6f22f509ce498aa909612259399 Mon Sep 17 00:00:00 2001 From: nissy-dev Date: Sat, 5 Nov 2022 17:23:21 +0900 Subject: [PATCH 3/5] fix: rename satisfaction to satisfies --- crates/swc_ecma_ast/src/expr.rs | 8 ++++---- crates/swc_ecma_ast/src/lib.rs | 2 +- crates/swc_ecma_ast/src/typescript.rs | 4 ++-- crates/swc_ecma_codegen/src/lib.rs | 2 +- crates/swc_ecma_codegen/src/typescript.rs | 2 +- crates/swc_ecma_codegen/src/util.rs | 4 +--- .../src/compress/optimize/sequences.rs | 2 +- crates/swc_ecma_minifier/src/util/size.rs | 2 +- crates/swc_ecma_parser/src/parser/expr/ops.rs | 2 +- crates/swc_ecma_parser/src/parser/util.rs | 2 +- .../tests/tsc/typeSatisfaction.json | 16 ++++++++-------- .../tsc/typeSatisfaction_contextualTyping1.json | 2 +- .../typeSatisfaction_ensureInterfaceImpl.json | 2 +- .../tests/tsc/typeSatisfaction_js.json | 2 +- ...peSatisfaction_optionalMemberConformance.json | 2 +- .../typeSatisfaction_propNameConstraining.json | 2 +- ...typeSatisfaction_propertyNameFulfillment.json | 2 +- ...peSatisfaction_propertyValueConformance1.json | 2 +- ...peSatisfaction_propertyValueConformance2.json | 2 +- ...peSatisfaction_propertyValueConformance3.json | 2 +- crates/swc_ecma_quote_macros/src/ast/expr.rs | 2 +- .../swc_ecma_quote_macros/src/ast/typescript.rs | 2 +- .../src/es2015/destructuring.rs | 2 +- .../swc_ecma_transforms_typescript/src/strip.rs | 2 +- crates/swc_ecma_utils/src/lib.rs | 4 ++-- crates/swc_ecma_visit/src/lib.rs | 2 +- crates/swc_estree_compat/src/babelify/expr.rs | 2 +- 27 files changed, 39 insertions(+), 41 deletions(-) diff --git a/crates/swc_ecma_ast/src/expr.rs b/crates/swc_ecma_ast/src/expr.rs index 5e3b5c19bcdc..428691c2a682 100644 --- a/crates/swc_ecma_ast/src/expr.rs +++ b/crates/swc_ecma_ast/src/expr.rs @@ -22,7 +22,7 @@ use crate::{ prop::Prop, stmt::BlockStmt, typescript::{ - TsAsExpr, TsConstAssertion, TsInstantiation, TsNonNullExpr, TsSatisfactionExpr, TsTypeAnn, + TsAsExpr, TsConstAssertion, TsInstantiation, TsNonNullExpr, TsSatisfiesExpr, TsTypeAnn, TsTypeAssertion, TsTypeParamDecl, TsTypeParamInstantiation, }, ComputedPropName, Id, Invalid, @@ -157,8 +157,8 @@ pub enum Expr { #[tag("TsInstantiation")] TsInstantiation(TsInstantiation), - #[tag("TsSatisfactionExpr")] - TsSatisfaction(TsSatisfactionExpr), + #[tag("TsSatisfiesExpression")] + TsSatisfies(TsSatisfiesExpr), #[tag("PrivateName")] PrivateName(PrivateName), @@ -271,7 +271,7 @@ impl Clone for Expr { PrivateName(e) => PrivateName(e.clone()), OptChain(e) => OptChain(e.clone()), Invalid(e) => Invalid(e.clone()), - TsSatisfaction(e) => TsSatisfaction(e.clone()), + TsSatisfies(e) => TsSatisfies(e.clone()), } } } diff --git a/crates/swc_ecma_ast/src/lib.rs b/crates/swc_ecma_ast/src/lib.rs index 4ed108c1814d..67a3b2f73a7f 100644 --- a/crates/swc_ecma_ast/src/lib.rs +++ b/crates/swc_ecma_ast/src/lib.rs @@ -68,7 +68,7 @@ pub use self::{ TsKeywordType, TsKeywordTypeKind, TsLit, TsLitType, TsMappedType, TsMethodSignature, TsModuleBlock, TsModuleDecl, TsModuleName, TsModuleRef, TsNamespaceBody, TsNamespaceDecl, TsNamespaceExportDecl, TsNonNullExpr, TsOptionalType, TsParamProp, TsParamPropParam, - TsParenthesizedType, TsPropertySignature, TsQualifiedName, TsRestType, TsSatisfactionExpr, + TsParenthesizedType, TsPropertySignature, TsQualifiedName, TsRestType, TsSatisfiesExpr, TsSetterSignature, TsThisType, TsThisTypeOrIdent, TsTplLitType, TsTupleElement, TsTupleType, TsType, TsTypeAliasDecl, TsTypeAnn, TsTypeAssertion, TsTypeElement, TsTypeLit, TsTypeOperator, TsTypeOperatorOp, TsTypeParam, TsTypeParamDecl, TsTypeParamInstantiation, diff --git a/crates/swc_ecma_ast/src/typescript.rs b/crates/swc_ecma_ast/src/typescript.rs index db9b892b20da..4e0441bbcf8c 100644 --- a/crates/swc_ecma_ast/src/typescript.rs +++ b/crates/swc_ecma_ast/src/typescript.rs @@ -1055,10 +1055,10 @@ pub struct TsNonNullExpr { pub expr: Box, } -#[ast_node("TsSatisfactionExpr")] +#[ast_node("TsSatisfiesExpression")] #[derive(Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] -pub struct TsSatisfactionExpr { +pub struct TsSatisfiesExpr { pub span: Span, #[serde(rename = "expression")] pub expr: Box, diff --git a/crates/swc_ecma_codegen/src/lib.rs b/crates/swc_ecma_codegen/src/lib.rs index 2b88143c8912..456dd0d8a766 100644 --- a/crates/swc_ecma_codegen/src/lib.rs +++ b/crates/swc_ecma_codegen/src/lib.rs @@ -794,7 +794,7 @@ where Expr::TsInstantiation(ref n) => emit!(n), Expr::OptChain(ref n) => emit!(n), Expr::Invalid(ref n) => emit!(n), - Expr::TsSatisfaction(n) => { + Expr::TsSatisfies(n) => { emit!(n) } } diff --git a/crates/swc_ecma_codegen/src/typescript.rs b/crates/swc_ecma_codegen/src/typescript.rs index df5955244e10..9ed7bf4f3b5e 100644 --- a/crates/swc_ecma_codegen/src/typescript.rs +++ b/crates/swc_ecma_codegen/src/typescript.rs @@ -40,7 +40,7 @@ where } #[emitter] - fn emit_ts_satisfaction_expr(&mut self, n: &TsSatisfactionExpr) -> Result { + fn emit_ts_satisfies_expr(&mut self, n: &TsSatisfiesExpr) -> Result { self.emit_leading_comments_of_span(n.span(), false)?; emit!(n.expr); diff --git a/crates/swc_ecma_codegen/src/util.rs b/crates/swc_ecma_codegen/src/util.rs index dfa3ab693809..c052b7460c74 100644 --- a/crates/swc_ecma_codegen/src/util.rs +++ b/crates/swc_ecma_codegen/src/util.rs @@ -142,9 +142,7 @@ impl StartsWithAlphaNum for Expr { | Expr::TsAs(TsAsExpr { ref expr, .. }) | Expr::TsConstAssertion(TsConstAssertion { ref expr, .. }) | Expr::TsInstantiation(TsInstantiation { ref expr, .. }) - | Expr::TsSatisfaction(TsSatisfactionExpr { ref expr, .. }) => { - expr.starts_with_alpha_num() - } + | Expr::TsSatisfies(TsSatisfiesExpr { ref expr, .. }) => expr.starts_with_alpha_num(), Expr::OptChain(OptChainExpr { base: OptChainBase::Member(MemberExpr { obj: expr, .. }), diff --git a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs index 507420b407d4..11e03c9000c5 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs @@ -1451,7 +1451,7 @@ where | Expr::TsNonNull(_) | Expr::TsAs(_) | Expr::TsInstantiation(_) - | Expr::TsSatisfaction(_) => false, + | Expr::TsSatisfies(_) => false, } } diff --git a/crates/swc_ecma_minifier/src/util/size.rs b/crates/swc_ecma_minifier/src/util/size.rs index 475a0f7a1374..d33386eb51f2 100644 --- a/crates/swc_ecma_minifier/src/util/size.rs +++ b/crates/swc_ecma_minifier/src/util/size.rs @@ -198,7 +198,7 @@ impl SizeWithCtxt for Expr { Expr::TsNonNull(_) => TODO, Expr::TsAs(_) => TODO, Expr::TsInstantiation(_) => TODO, - Expr::TsSatisfaction(_) => TODO, + Expr::TsSatisfies(_) => TODO, } } } diff --git a/crates/swc_ecma_parser/src/parser/expr/ops.rs b/crates/swc_ecma_parser/src/parser/expr/ops.rs index 149e8ac76dbd..4a407991b106 100644 --- a/crates/swc_ecma_parser/src/parser/expr/ops.rs +++ b/crates/swc_ecma_parser/src/parser/expr/ops.rs @@ -122,7 +122,7 @@ impl Parser { let expr = left; let node = { let type_ann = self.next_then_parse_ts_type()?; - Box::new(Expr::TsSatisfaction(TsSatisfactionExpr { + Box::new(Expr::TsSatisfies(TsSatisfiesExpr { span: span!(self, start), expr, type_ann, diff --git a/crates/swc_ecma_parser/src/parser/util.rs b/crates/swc_ecma_parser/src/parser/util.rs index 5c28d20485fb..0c96d9f56742 100644 --- a/crates/swc_ecma_parser/src/parser/util.rs +++ b/crates/swc_ecma_parser/src/parser/util.rs @@ -315,7 +315,7 @@ pub(super) trait ExprExt { | Expr::TsTypeAssertion(TsTypeAssertion { ref expr, .. }) | Expr::TsAs(TsAsExpr { ref expr, .. }) | Expr::TsInstantiation(TsInstantiation { ref expr, .. }) - | Expr::TsSatisfaction(TsSatisfactionExpr { ref expr, .. }) => { + | Expr::TsSatisfies(TsSatisfiesExpr { ref expr, .. }) => { expr.is_valid_simple_assignment_target(strict) } diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction.json index 49c05640ab4d..e3ea08a9467c 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction.json @@ -290,7 +290,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 110, "end": 131, @@ -382,7 +382,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 150, "end": 177, @@ -497,7 +497,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 199, "end": 215, @@ -591,7 +591,7 @@ } }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 242, "end": 265, @@ -683,7 +683,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 284, "end": 318, @@ -827,7 +827,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 338, "end": 371, @@ -1021,7 +1021,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 413, "end": 438, @@ -1113,7 +1113,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 449, "end": 485, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_contextualTyping1.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_contextualTyping1.json index c226e93a13fe..2abc0b0efd1e 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_contextualTyping1.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_contextualTyping1.json @@ -167,7 +167,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 71, "end": 153, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_ensureInterfaceImpl.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_ensureInterfaceImpl.json index 36b337b9618d..c302d07b2f6a 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_ensureInterfaceImpl.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_ensureInterfaceImpl.json @@ -133,7 +133,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 68, "end": 198, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.json index 31463f839391..036aed577333 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.json @@ -35,7 +35,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 71, "end": 92, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_optionalMemberConformance.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_optionalMemberConformance.json index 568b8745525b..11ddf2718fb6 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_optionalMemberConformance.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_optionalMemberConformance.json @@ -147,7 +147,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 103, "end": 139, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propNameConstraining.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propNameConstraining.json index e33e8145ca56..c2d6f7dbf8cc 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propNameConstraining.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propNameConstraining.json @@ -137,7 +137,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 47, "end": 163, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyNameFulfillment.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyNameFulfillment.json index f8f6227b4c79..47083711441b 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyNameFulfillment.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyNameFulfillment.json @@ -137,7 +137,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 47, "end": 154, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance1.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance1.json index 292a2c39226b..c8e11d600dc7 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance1.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance1.json @@ -681,7 +681,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 476, "end": 523, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance2.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance2.json index 107557ec0fad..3989c1beaa45 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance2.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance2.json @@ -681,7 +681,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 457, "end": 504, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance3.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance3.json index 091b20aab501..5002238a019f 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance3.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_propertyValueConformance3.json @@ -203,7 +203,7 @@ "typeAnnotation": null }, "init": { - "type": "TsSatisfactionExpr", + "type": "TsSatisfiesExpression", "span": { "start": 150, "end": 323, diff --git a/crates/swc_ecma_quote_macros/src/ast/expr.rs b/crates/swc_ecma_quote_macros/src/ast/expr.rs index f1651d8fe50c..75e1f6af819b 100644 --- a/crates/swc_ecma_quote_macros/src/ast/expr.rs +++ b/crates/swc_ecma_quote_macros/src/ast/expr.rs @@ -38,7 +38,7 @@ impl_enum!( TsNonNull, TsAs, TsInstantiation, - TsSatisfaction, + TsSatisfies, PrivateName, OptChain, Invalid diff --git a/crates/swc_ecma_quote_macros/src/ast/typescript.rs b/crates/swc_ecma_quote_macros/src/ast/typescript.rs index 79dc08a5eb97..589df60808ad 100644 --- a/crates/swc_ecma_quote_macros/src/ast/typescript.rs +++ b/crates/swc_ecma_quote_macros/src/ast/typescript.rs @@ -19,4 +19,4 @@ fail_todo!(TsTypeParamDecl); fail_todo!(TsExprWithTypeArgs); fail_todo!(TsIndexSignature); fail_todo!(TsParamProp); -fail_todo!(TsSatisfactionExpr); +fail_todo!(TsSatisfiesExpr); diff --git a/crates/swc_ecma_transforms_compat/src/es2015/destructuring.rs b/crates/swc_ecma_transforms_compat/src/es2015/destructuring.rs index d2c2669a8008..1a6b5feff40b 100644 --- a/crates/swc_ecma_transforms_compat/src/es2015/destructuring.rs +++ b/crates/swc_ecma_transforms_compat/src/es2015/destructuring.rs @@ -1210,7 +1210,7 @@ fn can_be_null(e: &Expr) -> bool { | Expr::TsTypeAssertion(TsTypeAssertion { ref expr, .. }) | Expr::TsConstAssertion(TsConstAssertion { ref expr, .. }) | Expr::TsInstantiation(TsInstantiation { ref expr, .. }) - | Expr::TsSatisfaction(TsSatisfactionExpr { ref expr, .. }) => can_be_null(expr), + | Expr::TsSatisfies(TsSatisfiesExpr { ref expr, .. }) => can_be_null(expr), Expr::Invalid(..) => unreachable!(), } diff --git a/crates/swc_ecma_transforms_typescript/src/strip.rs b/crates/swc_ecma_transforms_typescript/src/strip.rs index 923290b8ac2c..322d6920ca0a 100644 --- a/crates/swc_ecma_transforms_typescript/src/strip.rs +++ b/crates/swc_ecma_transforms_typescript/src/strip.rs @@ -437,7 +437,7 @@ where | Expr::TsTypeAssertion(TsTypeAssertion { expr, .. }) | Expr::TsConstAssertion(TsConstAssertion { expr, .. }) | Expr::TsInstantiation(TsInstantiation { expr, .. }) - | Expr::TsSatisfaction(TsSatisfactionExpr { expr, .. }) => { + | Expr::TsSatisfies(TsSatisfiesExpr { expr, .. }) => { expr.visit_mut_with(self); let expr = *expr.take(); *n = expr; diff --git a/crates/swc_ecma_utils/src/lib.rs b/crates/swc_ecma_utils/src/lib.rs index eacdffa6ec0d..545394b908b7 100644 --- a/crates/swc_ecma_utils/src/lib.rs +++ b/crates/swc_ecma_utils/src/lib.rs @@ -1489,7 +1489,7 @@ pub trait ExprExt { | Expr::TsNonNull(TsNonNullExpr { ref expr, .. }) | Expr::TsTypeAssertion(TsTypeAssertion { ref expr, .. }) | Expr::TsInstantiation(TsInstantiation { ref expr, .. }) - | Expr::TsSatisfaction(TsSatisfactionExpr { ref expr, .. }) => { + | Expr::TsSatisfies(TsSatisfiesExpr { ref expr, .. }) => { expr.may_have_side_effects(ctx) } @@ -2454,7 +2454,7 @@ impl ExprCtx { | Expr::TsAs(TsAsExpr { expr, .. }) | Expr::TsConstAssertion(TsConstAssertion { expr, .. }) | Expr::TsInstantiation(TsInstantiation { expr, .. }) - | Expr::TsSatisfaction(TsSatisfactionExpr { expr, .. }) => { + | Expr::TsSatisfies(TsSatisfiesExpr { expr, .. }) => { self.extract_side_effects_to(to, *expr) } Expr::OptChain(OptChainExpr { base: child, .. }) => { diff --git a/crates/swc_ecma_visit/src/lib.rs b/crates/swc_ecma_visit/src/lib.rs index 42faf58544ad..6d4d76a85661 100644 --- a/crates/swc_ecma_visit/src/lib.rs +++ b/crates/swc_ecma_visit/src/lib.rs @@ -660,7 +660,7 @@ define!({ TsConstAssertion(TsConstAssertion), TsNonNull(TsNonNullExpr), TsAs(TsAsExpr), - TsSatisfaction(TsSatisfactionExpr), + TsSatisfies(TsSatisfiesExpr), TsInstantiation(TsInstantiation), PrivateName(PrivateName), OptChain(OptChainExpr), diff --git a/crates/swc_estree_compat/src/babelify/expr.rs b/crates/swc_estree_compat/src/babelify/expr.rs index d10aeb45899f..cb1a990531e8 100644 --- a/crates/swc_estree_compat/src/babelify/expr.rs +++ b/crates/swc_estree_compat/src/babelify/expr.rs @@ -157,7 +157,7 @@ impl Babelify for Expr { "illegal conversion: Cannot convert {:?} to ExprOutput - babel has no equivalent", &self ), - Expr::TsSatisfaction(_) => panic!( + Expr::TsSatisfies(_) => panic!( "illegal conversion: Cannot convert {:?} to ExprOutput - babel has no equivalent", &self ), From c09f3ea7d7b2ee165468e1b84b466b93b23dc682 Mon Sep 17 00:00:00 2001 From: nissy-dev Date: Sun, 6 Nov 2022 21:38:02 +0900 Subject: [PATCH 4/5] fix: run `cargo update` for dependency patch --- .github/workflows/CI.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e61665dc0dd6..efc494b6d186 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -717,6 +717,7 @@ jobs: run: | echo '[patch.crates-io]' >> bindings/Cargo.toml ./scripts/cargo/patch-section.sh >> bindings/Cargo.toml + cd bindings && cargo update - name: Cache uses: actions/cache@v3 @@ -777,6 +778,7 @@ jobs: run: | echo '[patch.crates-io]' >> bindings/Cargo.toml ./scripts/cargo/patch-section.sh >> bindings/Cargo.toml + cd bindings && cargo update - name: Prepare run: | From 76c0c1d1c72fc4d451fe6559555c863c4c896bfd Mon Sep 17 00:00:00 2001 From: nissy-dev Date: Sun, 6 Nov 2022 23:05:28 +0900 Subject: [PATCH 5/5] fix: update snapshot --- node-swc/__tests__/transform/issue_4730_test.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node-swc/__tests__/transform/issue_4730_test.mjs b/node-swc/__tests__/transform/issue_4730_test.mjs index d80fa914e91b..1c9f1286d262 100644 --- a/node-swc/__tests__/transform/issue_4730_test.mjs +++ b/node-swc/__tests__/transform/issue_4730_test.mjs @@ -37,9 +37,9 @@ Object.defineProperty(exports, \\"__esModule\\", { value: true }); const _interopRequireWildcard = require(\\"@swc/helpers/lib/_interop_require_wildcard.js\\").default; -const _b = require(\\"../packages/b/src/index\\"); +const _b = require(\\"../packages/b/src/index.ts\\"); async function display() { - const displayA = await Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require(\\"../packages/a/src/index\\"))).then((c)=>c.displayA); + const displayA = await Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require(\\"../packages/a/src/index.ts\\"))).then((c)=>c.displayA); console.log(displayA()); console.log((0, _b.displayB)()); }