-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcomponentSelf.ts
More file actions
37 lines (36 loc) · 1.51 KB
/
componentSelf.ts
File metadata and controls
37 lines (36 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type { Code } from '../../types'
import type { ScriptCodegenOptions } from './index'
import { endOfLine, newLine } from '../utils'
import { getSlotsPropertyName } from '../../utils/shared'
export function* generateComponentSelf(
options: ScriptCodegenOptions,
): Generator<Code> {
if (options.sfc.scriptSetup) {
yield `type __VLS_SelfBase = `
if (options.scriptSetupRanges?.defineExpose) {
yield `typeof __VLS_defineExpose`
} else {
yield `{}`
}
yield endOfLine
yield `type __VLS_SelfComponent = __VLS_SelfBase & {${newLine}`
yield ` new (props: __VLS_PublicProps): __VLS_SelfBase & {${newLine}`
yield ` $props: __VLS_PublicProps${endOfLine}`
yield ` ${getSlotsPropertyName()}: __VLS_Slots${endOfLine}`
yield ` }${newLine}`
yield `}${endOfLine}`
yield `const __VLS_self = {} as __VLS_SelfComponent${endOfLine}`
} else {
yield `type __VLS_SelfProps = __VLS_GetPropsType<${newLine}`
yield ` NonNullable<typeof __VLS_defineComponent['$rawOptions']['properties']>${newLine}`
yield `>${endOfLine}`
yield `type __VLS_SelfComponent = typeof __VLS_defineComponent & {${newLine}`
yield ` new (props: __VLS_SelfProps): typeof __VLS_defineComponent & {${newLine}`
yield ` $props: __VLS_SelfProps${endOfLine}`
yield ` ${getSlotsPropertyName()}: __VLS_Slots${endOfLine}`
yield ` }${newLine}`
yield `}${endOfLine}`
yield `const __VLS_self = {} as __VLS_SelfComponent${endOfLine}`
}
yield `export default __VLS_self${endOfLine}`
}