Skip to content

Commit d929fdc

Browse files
committed
chore: fix docs:build
1 parent 128eb21 commit d929fdc

File tree

2 files changed

+43
-27
lines changed

2 files changed

+43
-27
lines changed

packages/runtime/src/vue.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ export declare class VaporComponentInstance<
9090
emitted: Record<string, boolean> | null
9191
expose: (<T extends Record<string, any> = Exposed>(exposed: T) => void) &
9292
string[]
93-
exposed: Exposed | null
94-
exposeProxy: ShallowUnwrapRef<Exposed> | null
93+
exposed: Record<string, any> extends Exposed ? Exposed | null : Exposed
94+
exposeProxy: Record<string, any> extends Exposed
95+
? Exposed | null
96+
: ShallowUnwrapRef<Exposed>
9597
refs: TypeRefs
9698
provides: Record<string, any>
9799
ids: [string, number, number]

packages/vue-jsx-vapor/src/volar/jsx-element.ts

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,54 @@ export default createPlugin(({ ts }) => {
55
return {
66
name: '@vue-jsx-vapor/jsx-element',
77
resolveVirtualCode({ ast, codes }) {
8+
let transformed = false
89
ast.forEachChild(function walk(
910
node,
1011
parent: import('typescript').Node = ast,
1112
) {
12-
node.forEachChild((child) => walk(child, node))
1313
if (
14-
ts.isJsxElement(parent) ||
15-
ts.isJsxFragment(parent) ||
16-
ts.isJsxExpression(parent) ||
17-
(parent.parent ? isConditionalExpression(ts, parent) : false)
14+
!ts.isJsxElement(parent) &&
15+
!ts.isJsxFragment(parent) &&
16+
!ts.isJsxExpression(parent) &&
17+
!(parent.parent ? isConditionalExpression(ts, parent) : false)
1818
) {
19-
return
19+
const openingElement = ts.isJsxElement(node)
20+
? node.openingElement
21+
: ts.isJsxSelfClosingElement(node)
22+
? node
23+
: null
24+
if (openingElement) {
25+
const tagName = openingElement.tagName.getText(ast)
26+
if (!tagName.includes('-')) {
27+
transformed = true
28+
codes.replaceRange(
29+
node.getStart(ast),
30+
node.getStart(ast) + 1,
31+
'(<',
32+
)
33+
codes.replaceRange(
34+
node.end,
35+
node.end,
36+
' as unknown as __InferJsxElement<',
37+
isHTMLTag(tagName) || isSVGTag(tagName)
38+
? `'${tagName}'`
39+
: `typeof ${tagName}`,
40+
'>)',
41+
)
42+
}
43+
}
2044
}
21-
const openingElement = ts.isJsxElement(node)
22-
? node.openingElement
23-
: ts.isJsxSelfClosingElement(node)
24-
? node
25-
: null
26-
if (openingElement) {
27-
const tagName = openingElement.tagName.getText(ast)
28-
if (tagName.includes('-')) return
29-
codes.replaceRange(node.getStart(ast), node.getStart(ast) + 1, '(<')
30-
codes.replaceRange(
31-
node.end,
32-
node.end,
33-
' as unknown as __InferJsxElement<',
34-
isHTMLTag(tagName) || isSVGTag(tagName)
35-
? `'${tagName}'`
36-
: `typeof ${tagName}`,
37-
'>)',
38-
)
45+
46+
if (
47+
!ts.isCallExpression(node) ||
48+
node.expression.getText(ast) !== 'defineSlots'
49+
) {
50+
node.forEachChild((child) => walk(child, node))
3951
}
4052
})
41-
codes.push(`
53+
54+
transformed &&
55+
codes.push(`
4256
type __InferJsxElement<T> = T extends keyof HTMLElementTagNameMap
4357
? HTMLElementTagNameMap[T]
4458
: T extends keyof SVGElementTagNameMap

0 commit comments

Comments
 (0)