'TSInstantiationExpression', // foo<string>
'TSSatisfiesExpression' // foo satisfies T
]
+
+export function unwrapTSNode(node: Node): Node {
+ if (TS_NODE_TYPES.includes(node.type)) {
+ return unwrapTSNode((node as any).expression)
+ } else {
+ return node
+ }
+}
import { PropsExpression } from './transforms/transformElement'
import { parseExpression } from '@babel/parser'
import { Expression } from '@babel/types'
+import { unwrapTSNode } from './babelUtils'
export const isStaticExp = (p: JSChildNode): p is SimpleExpressionNode =>
p.type === NodeTypes.SIMPLE_EXPRESSION && p.isStatic
let ret: Expression = parseExpression(path, {
plugins: context.expressionPlugins
})
- if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
- ret = ret.expression
- }
+ ret = unwrapTSNode(ret) as Expression
return (
ret.type === 'MemberExpression' ||
ret.type === 'OptionalMemberExpression' ||
BindingTypes,
UNREF,
isFunctionType,
- walkIdentifiers
+ walkIdentifiers,
+ unwrapTSNode
} from '@vue/compiler-dom'
import { DEFAULT_FILENAME, SFCDescriptor, SFCScriptBlock } from './parse'
import { ParserPlugin } from '@babel/parser'
import { DEFINE_OPTIONS, processDefineOptions } from './script/defineOptions'
import { processDefineSlots } from './script/defineSlots'
import { DEFINE_MODEL, processDefineModel } from './script/defineModel'
-import {
- isLiteralNode,
- unwrapTSNode,
- isCallOf,
- getImportedName
-} from './script/utils'
+import { isLiteralNode, isCallOf, getImportedName } from './script/utils'
import { analyzeScriptBindings } from './script/analyzeScriptBindings'
import { isImportUsed } from './script/importUsageCheck'
import { processAwait } from './script/topLevelAwait'
UNKNOWN_TYPE,
concatStrings,
isCallOf,
- toRuntimeTypeString,
- unwrapTSNode
+ toRuntimeTypeString
} from './utils'
-import { BindingTypes } from '@vue/compiler-dom'
+import { BindingTypes, unwrapTSNode } from '@vue/compiler-dom'
import { warnOnce } from '../warn'
export const DEFINE_MODEL = 'defineModel'
import { Node } from '@babel/types'
+import { unwrapTSNode } from '@vue/compiler-dom'
import { ScriptCompileContext } from './context'
-import { isCallOf, unwrapTSNode } from './utils'
+import { isCallOf } from './utils'
import { DEFINE_PROPS } from './defineProps'
import { DEFINE_EMITS } from './defineEmits'
import { DEFINE_EXPOSE } from './defineExpose'
ObjectExpression,
Expression
} from '@babel/types'
-import { BindingTypes, isFunctionType } from '@vue/compiler-dom'
+import { BindingTypes, isFunctionType, unwrapTSNode } from '@vue/compiler-dom'
import { ScriptCompileContext } from './context'
import {
TypeResolveContext,
concatStrings,
isLiteralNode,
isCallOf,
- unwrapTSNode,
toRuntimeTypeString,
getEscapedPropName
} from './utils'
isInDestructureAssignment,
isReferencedIdentifier,
isStaticProperty,
- walkFunctionParams
+ walkFunctionParams,
+ unwrapTSNode
} from '@vue/compiler-dom'
import { genPropsAccessExp } from '@vue/shared'
-import { isCallOf, resolveObjectKey, unwrapTSNode } from './utils'
+import { isCallOf, resolveObjectKey } from './utils'
import { ScriptCompileContext } from './context'
import { DEFINE_PROPS } from './defineProps'
import { warnOnce } from '../warn'
StringLiteral
} from '@babel/types'
import path from 'path'
-import { TS_NODE_TYPES } from '@vue/compiler-dom'
export const UNKNOWN_TYPE = 'Unknown'
return node.type.endsWith('Literal')
}
-export function unwrapTSNode(node: Node): Node {
- if (TS_NODE_TYPES.includes(node.type)) {
- return unwrapTSNode((node as any).expression)
- } else {
- return node
- }
-}
-
export function isCallOf(
node: Node | null | undefined,
test: string | ((id: string) => boolean) | null | undefined