Skip to content

test: unknown props on non-strict generic component #4792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: allow unknown props on non-strict generic component
  • Loading branch information
KazariEX committed Sep 2, 2024
commit dcfaeab5f2694bffa9e19b1417573e9b130bcfd6
2 changes: 1 addition & 1 deletion packages/language-core/lib/codegen/script/scriptSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function* generateScriptSetup(
}

yield ` return {} as {${newLine}`
+ ` props: ${ctx.localTypes.PrettifyLocal}<typeof __VLS_functionalComponentProps & __VLS_PublicProps> & __VLS_BuiltInPublicProps,${newLine}`
+ ` props: ${ctx.localTypes.PrettifyLocal}<typeof __VLS_functionalComponentProps & __VLS_PublicProps> & __VLS_BuiltInPublicProps${options.vueCompilerOptions.strictTemplates ? `` : ` & Record<string, unknown>`},${newLine}`
+ ` expose(exposed: import('${options.vueCompilerOptions.lib}').ShallowUnwrapRef<${scriptSetupRanges.expose.define ? 'typeof __VLS_exposed' : '{}'}>): void,${newLine}`
+ ` attrs: any,${newLine}`
+ ` slots: __VLS_TemplateResult['slots'],${newLine}`
Expand Down
8 changes: 4 additions & 4 deletions packages/tsc/tests/__snapshots__/dts.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare const _default: <Row extends BaseRow>(__VLS_props: NonNullable<Awaited<t
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{}>>, never>, never> & {
nonGeneric: string;
rows: Row[];
}> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps);
}> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps) & Record<string, unknown>;
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
attrs: any;
slots: {
Expand Down Expand Up @@ -73,7 +73,7 @@ exports[`vue-tsc-dts > Input: events/component-generic.vue, Output: events/compo
onFoo?: (value: string) => any;
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<import("vue").ExtractPropTypes<{}>> & {
onFoo?: (value: string) => any;
}, never>, "onFoo"> & {}> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps);
}, never>, "onFoo"> & {}> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps) & Record<string, unknown>;
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
attrs: any;
slots: {};
Expand Down Expand Up @@ -102,7 +102,7 @@ exports[`vue-tsc-dts > Input: generic/component.vue, Output: generic/component.v
title?: string;
} & {
foo: number;
})> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps);
})> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps) & Record<string, unknown>;
expose(exposed: import("vue").ShallowUnwrapRef<{
baz: number;
}>): void;
Expand Down Expand Up @@ -141,7 +141,7 @@ exports[`vue-tsc-dts > Input: generic/custom-extension-component.cext, Output: g
title?: string;
} & {
foo: number;
})> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps);
})> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps) & Record<string, unknown>;
expose(exposed: import("vue").ShallowUnwrapRef<{
baz: number;
}>): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ declare const ScriptSetupGenericExact: <T, >(
props: {
readonly onBar?: ((data: T) => any) | undefined;
foo: T;
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps,
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Record<string, unknown>,
attrs: any,
slots: Readonly<{ default?(data: T): any; }> & { default?(data: T): any; },
emit: { (e: 'bar', data: T): void; },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare const ScriptSetupGenericExact: <T, >(
b?: T | undefined;
c?: T | undefined;
d: T;
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps,
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Record<string, unknown>,
attrs: any,
slots: {},
emit: {},
Expand Down
7 changes: 7 additions & 0 deletions test-workspace/tsc/passedFixtures/vue3/#4785/generic.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script setup lang="ts" generic="T">
defineProps<{
foo: T
}>();
</script>

<template></template>
7 changes: 7 additions & 0 deletions test-workspace/tsc/passedFixtures/vue3/#4785/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script setup lang="ts">
import Generic from './generic.vue';
</script>

<template>
<Generic :foo="1" aria-atomic/>
</template>
2 changes: 1 addition & 1 deletion test-workspace/tsc/passedFixtures/vue3/components/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ declare const ScriptSetupGenericExact: <T, >(
props: {
onBar?: ((data: T) => any) | undefined;
foo: T;
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps,
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Record<string, unknown>,
attrs: any,
slots: Readonly<{ default?(data: T): any; }> & { default?(data: T): any; },
emit: { (e: 'bar', data: T): void; },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare const ScriptSetupGenericExact: <T, >(
b?: T | undefined;
c?: T | undefined;
d: T;
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps,
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Record<string, unknown>,
attrs: any,
slots: {},
emit: {},
Expand Down