|
|
@@ -19,6 +19,7 @@ import {
|
|
|
} from '../ast'
|
|
|
import {
|
|
|
isInDestructureAssignment,
|
|
|
+ isInNewExpression,
|
|
|
isStaticProperty,
|
|
|
isStaticPropertyKey,
|
|
|
walkIdentifiers,
|
|
|
@@ -131,6 +132,11 @@ export function processExpression(
|
|
|
// ({ x } = y)
|
|
|
const isDestructureAssignment =
|
|
|
parent && isInDestructureAssignment(parent, parentStack)
|
|
|
+ const isNewExpression = parent && isInNewExpression(parentStack)
|
|
|
+ const wrapWithUnref = (raw: string) => {
|
|
|
+ const wrapped = `${context.helperString(UNREF)}(${raw})`
|
|
|
+ return isNewExpression ? `(${wrapped})` : wrapped
|
|
|
+ }
|
|
|
|
|
|
if (
|
|
|
isConst(type) ||
|
|
|
@@ -147,7 +153,7 @@ export function processExpression(
|
|
|
// that assumes the value to be a ref for more efficiency
|
|
|
return isAssignmentLVal || isUpdateArg || isDestructureAssignment
|
|
|
? `${raw}.value`
|
|
|
- : `${context.helperString(UNREF)}(${raw})`
|
|
|
+ : wrapWithUnref(raw)
|
|
|
} else if (type === BindingTypes.SETUP_LET) {
|
|
|
if (isAssignmentLVal) {
|
|
|
// let binding.
|
|
|
@@ -190,7 +196,7 @@ export function processExpression(
|
|
|
// for now
|
|
|
return raw
|
|
|
} else {
|
|
|
- return `${context.helperString(UNREF)}(${raw})`
|
|
|
+ return wrapWithUnref(raw)
|
|
|
}
|
|
|
} else if (type === BindingTypes.PROPS) {
|
|
|
// use __props which is generated by compileScript so in ts mode
|