@@ -67,6 +67,7 @@ const genaratorWebTypes = () => {
6767 absolutePath = path . join ( `${ basePath } /${ componentDir } ` , `doc.taro.md` )
6868 }
6969 let attributes = [ ]
70+ const events = [ ]
7071 if ( ! fs . existsSync ( absolutePath ) ) continue
7172 const data = fs . readFileSync ( absolutePath , 'utf8' )
7273 let sources = MarkdownIt . parse ( data , { } )
@@ -79,21 +80,42 @@ const genaratorWebTypes = () => {
7980 const infoItem = inlineItem . length ? `${ inlineItem [ 1 ] ?. content } ` : ''
8081 const typeItem = inlineItem . length ? `${ inlineItem [ 2 ] ?. content ?. toLowerCase ( ) } ` : ''
8182 const defaultItem = inlineItem . length ? `${ inlineItem [ 3 ] ?. content } ` : ''
82- attributes . push ( {
83+ const attribute = {
8384 name : propItem ,
8485 default : defaultItem ,
8586 description : infoItem ,
8687 value : {
8788 type : typeItem ,
8889 kind : 'expression'
8990 }
90- } )
91+ }
92+ if ( propItem === 'v-model' ) {
93+ const modelValue = 'modelValue'
94+ // add `modelValue`
95+ attributes . push ( { ...attribute , name : modelValue } )
96+ if ( typeItem === 'boolean' ) {
97+ // fix: warning `is not a valid value for v-model` in JetBrains IDE
98+ // ref: https://github.com/JetBrains/web-types/issues/79#issuecomment-2045153333
99+ attribute . value = { ...attribute . value , type : typeItem + ' ' }
100+ }
101+ events . push ( {
102+ name : `update:${ modelValue } ` ,
103+ description : `${ infoItem } \n\nEmitted when the value of \`${ modelValue } \` prop changes.` ,
104+ arguments : [
105+ {
106+ name : modelValue ,
107+ type : typeItem
108+ }
109+ ]
110+ } )
111+ }
112+ attributes . push ( attribute )
91113 }
92114 let compoName = kebabCase ( getCompName ( componentDir ) )
93115 typesData . contributions . html . tags . push ( {
94116 name : `nut-${ compoName } ` ,
95117 slots : [ ] ,
96- events : [ ] ,
118+ events,
97119 attributes : attributes . slice ( )
98120 } )
99121 }
0 commit comments