Skip to content

Commit 541cf78

Browse files
yoyo930021octref
authored andcommitted
1 parent e21eae3 commit 541cf78

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

server/src/services/typescriptService/preprocess.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,13 @@ function convertChildComponentsInfoToSource(childComponents: ChildComponent[]) {
299299

300300
const propTypeStrings: string[] = [];
301301
c.info?.componentInfo.props?.forEach(p => {
302-
let typeKey = p.required ? kebabCase(p.name) : kebabCase(p.name) + '?';
303-
if (typeKey.indexOf('-') !== -1) {
302+
let typeKey = kebabCase(p.name);
303+
if (typeKey.includes('-')) {
304304
typeKey = `'` + typeKey + `'`;
305305
}
306+
if (!p.required) {
307+
typeKey += '?';
308+
}
306309

307310
if (p.typeString) {
308311
propTypeStrings.push(`${typeKey}: ${p.typeString}`);

test/interpolation/fixture/diagnostics/propTypeValidation/TSChild.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export default Vue.extend({
88
callback: {
99
type: Function as PropType<() => void>
1010
},
11-
arr: Array as PropType<string[]>
11+
arr: Array as PropType<string[]>,
12+
darkMode: { type: Boolean, default: false }
1213
}
1314
});
1415
</script>

0 commit comments

Comments
 (0)