Skip to content

Commit

Permalink
Merge pull request #2342 from yoyo930021/fix-2314
Browse files Browse the repository at this point in the history
Fix error when optional camel-cased props are missing
  • Loading branch information
octref authored Oct 30, 2020
2 parents e21eae3 + ed77808 commit 962b035
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- 🙌 Respect typescript language settings. Thanks to contribution from [@yoyo930021](https://github.com/yoyo930021). #2109 and #2375.
- 🙌 Slim syntax highlighting. Thanks to contribution from [@Antti](https://github.com/Antti).
- 🙌 Stop computing outdated diagnostics with CancellationToken. Thanks to contribution from [@yoyo930021](https://github.com/yoyo930021). #1263 and #2332.
- 🙌 Fix error when optional camel-cased props are missing. Thanks to contribution from [@yoyo930021](https://github.com/yoyo930021). #2314 and #2342.

### 0.28.0 | 2020-09-23 | [VSIX](https://marketplace.visualstudio.com/_apis/public/gallery/publishers/octref/vsextensions/vetur/0.28.0/vspackage)

Expand Down
7 changes: 5 additions & 2 deletions server/src/services/typescriptService/preprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,13 @@ function convertChildComponentsInfoToSource(childComponents: ChildComponent[]) {

const propTypeStrings: string[] = [];
c.info?.componentInfo.props?.forEach(p => {
let typeKey = p.required ? kebabCase(p.name) : kebabCase(p.name) + '?';
if (typeKey.indexOf('-') !== -1) {
let typeKey = kebabCase(p.name);
if (typeKey.includes('-')) {
typeKey = `'` + typeKey + `'`;
}
if (!p.required) {
typeKey += '?';
}

if (p.typeString) {
propTypeStrings.push(`${typeKey}: ${p.typeString}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default Vue.extend({
callback: {
type: Function as PropType<() => void>
},
arr: Array as PropType<string[]>
arr: Array as PropType<string[]>,
camelCase: { type: Boolean, default: false }
}
});
</script>
3 changes: 2 additions & 1 deletion test/vue3/fixture/diagnostics/propTypeValidation/TSChild.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default defineComponent({
callback: {
type: Function as PropType<() => void>
},
arr: Array as PropType<string[]>
arr: Array as PropType<string[]>,
camelCase: { type: Boolean, default: false }
}
});
</script>

0 comments on commit 962b035

Please sign in to comment.