Skip to content

Commit

Permalink
mark mergeDefaults as pure function
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Feb 1, 2024
1 parent 65fac62 commit 400c48b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions visitor/src/resolve_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::VueJsxTransformVisitor;
use indexmap::{IndexMap, IndexSet};
use std::borrow::Cow;
use swc_core::{
common::{comments::Comments, EqIgnoreSpan, Spanned, DUMMY_SP},
common::{comments::Comments, EqIgnoreSpan, Span, Spanned, DUMMY_SP},
ecma::{
ast::*,
atoms::{js_word, JsWord},
Expand Down Expand Up @@ -172,7 +172,13 @@ where
},
],
type_args: None,
span: DUMMY_SP,
span: if let Some(comments) = &self.comments {
let span = Span::dummy_with_cmt();
comments.add_pure_comment(span.lo);
span
} else {
DUMMY_SP
},
})
}
None => Expr::Object(self.build_props_type(first_param_type, None)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ defineComponent((props: {
} = {
...defaults
})=>{}, {
props: _mergeDefaults({
props: /*#__PURE__*/ _mergeDefaults({
foo: {
type: String,
required: false
Expand All @@ -93,7 +93,7 @@ defineComponent((props: {
bar?: number;
baz: boolean;
} = defaults)=>{}, {
props: _mergeDefaults({
props: /*#__PURE__*/ _mergeDefaults({
foo: {
type: String,
required: false
Expand All @@ -115,7 +115,7 @@ defineComponent((props: {
return 'foo';
}
})=>{}, {
props: _mergeDefaults({
props: /*#__PURE__*/ _mergeDefaults({
foo: {
type: Function,
required: false
Expand Down

0 comments on commit 400c48b

Please sign in to comment.