1- import type * as ts from 'typescript' ;
21import type { VueCompilerOptions } from '../types' ;
32import { getSlotsPropertyName } from '../utils/shared' ;
43import { endOfLine } from './utils' ;
54
6- export function getLocalTypesGenerator ( compilerOptions : ts . CompilerOptions , vueCompilerOptions : VueCompilerOptions ) {
5+ export function getLocalTypesGenerator ( vueCompilerOptions : VueCompilerOptions ) {
76const used = new Set < string > ( ) ;
87
98const OmitKeepDiscriminatedUnion = defineHelper (
@@ -19,7 +18,7 @@ type __VLS_OmitKeepDiscriminatedUnion<T, K extends keyof any> = T extends any
1918( ) => `
2019type __VLS_WithDefaults<P, D> = {
2120[K in keyof Pick<P, keyof P>]: K extends keyof D
22- ? ${ PrettifyLocal . name } <P[K] & { default: D[K]}>
21+ ? ${ PrettifyLocal . name } <P[K] & { default: D[K] }>
2322: P[K]
2423};
2524` . trimStart ( )
@@ -59,19 +58,10 @@ type __VLS_PropsChildren<S> = {
5958) ;
6059const TypePropsToOption = defineHelper (
6160`__VLS_TypePropsToOption` ,
62- ( ) => compilerOptions . exactOptionalPropertyTypes ?
63- `
64- type __VLS_TypePropsToOption<T> = {
65- [K in keyof T]-?: {} extends Pick<T, K>
66- ? { type: import('${ vueCompilerOptions . lib } ').PropType<T[K]> }
67- : { type: import('${ vueCompilerOptions . lib } ').PropType<T[K]>, required: true }
68- };
69- ` . trimStart ( ) :
70- `
71- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
61+ ( ) => `
7262type __VLS_TypePropsToOption<T> = {
7363[K in keyof T]-?: {} extends Pick<T, K>
74- ? { type: import('${ vueCompilerOptions . lib } ').PropType<__VLS_NonUndefinedable<T [K]> > }
64+ ? { type: import('${ vueCompilerOptions . lib } ').PropType<Required<T> [K]> }
7565: { type: import('${ vueCompilerOptions . lib } ').PropType<T[K]>, required: true }
7666};
7767` . trimStart ( )
0 commit comments