@@ -22,8 +22,6 @@ export function getComponentProps(
2222 return ;
2323 }
2424 const vueCode = volarFile . generated . root ;
25- const program = languageService . getProgram ( ) ! ;
26- const checker = program . getTypeChecker ( ) ;
2725 const components = getVariableType ( ts , languageService , vueCode , '__VLS_components' ) ;
2826 if ( ! components ) {
2927 return [ ] ;
@@ -35,26 +33,16 @@ export function getComponentProps(
3533 }
3634
3735 const result = new Map < string , ComponentPropInfo > ( ) ;
36+ const program = languageService . getProgram ( ) ! ;
37+ const checker = program . getTypeChecker ( ) ;
3838
3939 for ( const sig of componentType . getCallSignatures ( ) ) {
4040 const propParam = sig . parameters [ 0 ] ;
4141 if ( propParam ) {
4242 const propsType = checker . getTypeOfSymbolAtLocation ( propParam , components . node ) ;
4343 const props = propsType . getProperties ( ) ;
4444 for ( const prop of props ) {
45- const name = prop . name ;
46- const required = ! ( prop . flags & ts . SymbolFlags . Optional ) || undefined ;
47- const {
48- content : commentMarkdown ,
49- deprecated
50- } = generateCommentMarkdown ( prop . getDocumentationComment ( checker ) , prop . getJsDocTags ( ) ) ;
51-
52- result . set ( name , {
53- name,
54- required,
55- deprecated,
56- commentMarkdown
57- } ) ;
45+ handlePropSymbol ( prop ) ;
5846 }
5947 }
6048 }
@@ -66,27 +54,44 @@ export function getComponentProps(
6654 const propsType = checker . getTypeOfSymbolAtLocation ( propsSymbol , components . node ) ;
6755 const props = propsType . getProperties ( ) ;
6856 for ( const prop of props ) {
69- if ( prop . flags & ts . SymbolFlags . Method ) { // #2443
70- continue ;
71- }
72- const name = prop . name ;
73- const required = ! ( prop . flags & ts . SymbolFlags . Optional ) || undefined ;
74- const {
75- content : commentMarkdown ,
76- deprecated
77- } = generateCommentMarkdown ( prop . getDocumentationComment ( checker ) , prop . getJsDocTags ( ) ) ;
78-
79- result . set ( name , {
80- name,
81- required,
82- deprecated,
83- commentMarkdown
84- } ) ;
57+ handlePropSymbol ( prop ) ;
8558 }
8659 }
8760 }
8861
8962 return [ ...result . values ( ) ] ;
63+
64+ function handlePropSymbol ( prop : ts . Symbol ) {
65+ if ( prop . flags & ts . SymbolFlags . Method ) { // #2443
66+ return ;
67+ }
68+ const name = prop . name ;
69+ const required = ! ( prop . flags & ts . SymbolFlags . Optional ) || undefined ;
70+ const {
71+ content : commentMarkdown ,
72+ deprecated,
73+ } = generateCommentMarkdown ( prop . getDocumentationComment ( checker ) , prop . getJsDocTags ( ) ) ;
74+ const values : any [ ] = [ ] ;
75+ const type = checker . getTypeOfSymbol ( prop ) ;
76+ const subTypes : ts . Type [ ] | undefined = ( type as any ) . types ;
77+
78+ if ( subTypes ) {
79+ for ( const subType of subTypes ) {
80+ const value = ( subType as any ) . value ;
81+ if ( value ) {
82+ values . push ( value ) ;
83+ }
84+ }
85+ }
86+
87+ result . set ( name , {
88+ name,
89+ required,
90+ deprecated,
91+ commentMarkdown,
92+ values,
93+ } ) ;
94+ }
9095}
9196
9297function generateCommentMarkdown ( parts : ts . SymbolDisplayPart [ ] , jsDocTags : ts . JSDocTagInfo [ ] ) {
0 commit comments