Skip to content

Commit 6a9b56c

Browse files
committed
wip: defineContext()
1 parent dc098c7 commit 6a9b56c

File tree

10 files changed

+199
-141
lines changed

10 files changed

+199
-141
lines changed

packages/compiler-core/src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export type HoistTransform = (
6262
) => void
6363

6464
export interface BindingMetadata {
65-
[key: string]: 'data' | 'props' | 'setup' | 'options' | 'component-import'
65+
[key: string]: 'data' | 'props' | 'setup' | 'options' | 'setup-raw'
6666
}
6767

6868
interface SharedTransformCodegenOptions {

packages/compiler-core/src/transforms/transformElement.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ export function resolveComponentType(
270270
`${context.helperString(UNREF)}(${tagFromSetup})`
271271
: `$setup[${JSON.stringify(tagFromSetup)}]`
272272
}
273-
const tagFromImport = checkType('component-import')
273+
const tagFromImport = checkType('setup-raw')
274274
if (tagFromImport) {
275-
// imports can be used as-is
275+
// raw setup bindings (e.g. imports) can be used as-is
276276
return tagFromImport
277277
}
278278
}

packages/compiler-core/src/transforms/transformExpression.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ export function processExpression(
105105
// setup inline mode
106106
if (type === 'setup') {
107107
return `${context.helperString(UNREF)}(${raw})`
108-
} else if (type === 'component-import') {
108+
} else if (type === 'props') {
109+
// use __props which is generated by compileScript so in ts mode
110+
// it gets correct type
111+
return `__props.${raw}`
112+
} else if (type === 'setup-raw') {
109113
return raw
110114
}
111115
}

0 commit comments

Comments
 (0)