Skip to content

Commit 233b7fb

Browse files
committed
fix: should not make $props optional
1 parent 5a02676 commit 233b7fb

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

packages/language-core/lib/codegen/globalTypes.ts

-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ export function generateGlobalTypes(lib: string, target: number, strictTemplates
119119
? T | __VLS_unknownDirective
120120
: NonNullable<(T & Record<string, __VLS_unknownDirective>)['created' | 'beforeMount' | 'mounted' | 'beforeUpdate' | 'updated' | 'beforeUnmount' | 'unmounted']>;
121121
function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K;
122-
function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
123122
function __VLS_nonNullable<T>(t: T): T extends null | undefined ? never : T;
124123
function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
125124
T extends new (...args: any) => any

packages/language-core/lib/codegen/script/component.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ export function* generateComponent(
5252
export function* generateComponentSetupReturns(scriptSetupRanges: ScriptSetupRanges): Generator<Code> {
5353
// fill $props
5454
if (scriptSetupRanges.props.define) {
55-
// NOTE: defineProps is inaccurate for $props
56-
yield `$props: __VLS_makeOptional(${scriptSetupRanges.props.name ?? `__VLS_props`}),${newLine}`;
55+
yield `$props: ${scriptSetupRanges.props.name ?? `__VLS_props`},${newLine}`;
5756
yield `...${scriptSetupRanges.props.name ?? `__VLS_props`},${newLine}`;
5857
}
5958
// fill $emit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script setup>
2+
defineProps({
3+
msg: {
4+
type: String,
5+
required: true
6+
}
7+
})
8+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script lang="ts" setup>
2+
import Child from './child.vue';
3+
</script>
4+
5+
<template>
6+
<!-- @vue-expect-error -->
7+
<Child />
8+
</template>

0 commit comments

Comments
 (0)