wip: defineContext()

This commit is contained in:
Evan You
2020-11-12 14:10:39 -05:00
parent dc098c7f81
commit 6a9b56ca60
10 changed files with 200 additions and 142 deletions

View File

@@ -62,7 +62,7 @@ export type HoistTransform = (
) => void
export interface BindingMetadata {
[key: string]: 'data' | 'props' | 'setup' | 'options' | 'component-import'
[key: string]: 'data' | 'props' | 'setup' | 'options' | 'setup-raw'
}
interface SharedTransformCodegenOptions {

View File

@@ -270,9 +270,9 @@ export function resolveComponentType(
`${context.helperString(UNREF)}(${tagFromSetup})`
: `$setup[${JSON.stringify(tagFromSetup)}]`
}
const tagFromImport = checkType('component-import')
const tagFromImport = checkType('setup-raw')
if (tagFromImport) {
// imports can be used as-is
// raw setup bindings (e.g. imports) can be used as-is
return tagFromImport
}
}

View File

@@ -105,7 +105,11 @@ export function processExpression(
// setup inline mode
if (type === 'setup') {
return `${context.helperString(UNREF)}(${raw})`
} else if (type === 'component-import') {
} else if (type === 'props') {
// use __props which is generated by compileScript so in ts mode
// it gets correct type
return `__props.${raw}`
} else if (type === 'setup-raw') {
return raw
}
}