Skip to content

Commit

Permalink
fix: warning is not a valid value for v-model in JetBrains IDE (#3029)
Browse files Browse the repository at this point in the history
  • Loading branch information
anyesu authored Apr 15, 2024
1 parent 7cd3ce9 commit 315c17d
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions scripts/createAttributes.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const genaratorWebTypes = () => {
absolutePath = path.join(`${basePath}/${componentDir}`, `doc.taro.md`)
}
let attributes = []
const events = []
if (!fs.existsSync(absolutePath)) continue
const data = fs.readFileSync(absolutePath, 'utf8')
let sources = MarkdownIt.parse(data, {})
Expand All @@ -79,21 +80,42 @@ const genaratorWebTypes = () => {
const infoItem = inlineItem.length ? `${inlineItem[1]?.content}` : ''
const typeItem = inlineItem.length ? `${inlineItem[2]?.content?.toLowerCase()}` : ''
const defaultItem = inlineItem.length ? `${inlineItem[3]?.content}` : ''
attributes.push({
const attribute = {
name: propItem,
default: defaultItem,
description: infoItem,
value: {
type: typeItem,
kind: 'expression'
}
})
}
if (propItem === 'v-model') {
const modelValue = 'modelValue'
// add `modelValue`
attributes.push({ ...attribute, name: modelValue })
if (typeItem === 'boolean') {
// fix: warning `is not a valid value for v-model` in JetBrains IDE
// ref: https://github.com/JetBrains/web-types/issues/79#issuecomment-2045153333
attribute.value = { ...attribute.value, type: typeItem + ' ' }
}
events.push({
name: `update:${modelValue}`,
description: `${infoItem}\n\nEmitted when the value of \`${modelValue}\` prop changes.`,
arguments: [
{
name: modelValue,
type: typeItem
}
]
})
}
attributes.push(attribute)
}
let compoName = kebabCase(getCompName(componentDir))
typesData.contributions.html.tags.push({
name: `nut-${compoName}`,
slots: [],
events: [],
events,
attributes: attributes.slice()
})
}
Expand Down

0 comments on commit 315c17d

Please sign in to comment.