Skip to content

fix(language-core): Prettify<T> breaks generics inferencing #5424

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion packages/language-core/lib/codegen/globalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export function generateGlobalTypes({
type __VLS_ResolveDirectives<T> = {
[K in Exclude<keyof T, keyof __VLS_GlobalDirectives> & string as \`v\${Capitalize<K>}\`]: T[K];
};
type __VLS_PrettifyGlobal<T> = { [K in keyof T]: T[K]; } & {};
type __VLS_PrettifyGlobal<T> = { [K in keyof T as K]: T[K]; } & {};
type __VLS_UseTemplateRef<T> = Readonly<import('${lib}').ShallowRef<T | null>>;

function __VLS_getVForSourceType<T extends number | string | any[] | Iterable<any>>(source: T): [
Expand Down
2 changes: 1 addition & 1 deletion packages/language-core/lib/codegen/localTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type __VLS_WithDefaults<P, D> = {
);
const PrettifyLocal = defineHelper(
`__VLS_PrettifyLocal`,
() => `type __VLS_PrettifyLocal<T> = { [K in keyof T]: T[K]; } & {}${endOfLine}`
() => `type __VLS_PrettifyLocal<T> = { [K in keyof T as K]: T[K]; } & {}${endOfLine}`
);
const WithSlots = defineHelper(
`__VLS_WithSlots`,
Expand Down
6 changes: 3 additions & 3 deletions packages/tsc/tests/__snapshots__/dts.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ declare const _default: <Row extends BaseRow>(__VLS_props: NonNullable<Awaited<t
};
export default _default;
type __VLS_PrettifyLocal<T> = {
[K in keyof T]: T[K];
[K in keyof T as K]: T[K];
} & {};
"
`;
Expand Down Expand Up @@ -104,7 +104,7 @@ exports[`vue-tsc-dts > Input: generic/component.vue, Output: generic/component.v
};
export default _default;
type __VLS_PrettifyLocal<T> = {
[K in keyof T]: T[K];
[K in keyof T as K]: T[K];
} & {};
"
`;
Expand Down Expand Up @@ -134,7 +134,7 @@ exports[`vue-tsc-dts > Input: generic/custom-extension-component.cext, Output: g
};
export default _default;
type __VLS_PrettifyLocal<T> = {
[K in keyof T]: T[K];
[K in keyof T as K]: T[K];
} & {};
"
`;
Expand Down
7 changes: 7 additions & 0 deletions test-workspace/tsc/passedFixtures/vue3/#5159/child.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script setup lang="ts" generic="T extends keyof HTMLElementTagNameMap = 'h1'">
defineProps<
Partial<HTMLElementTagNameMap[T]> & {
as?: T;
}
>();
</script>
7 changes: 7 additions & 0 deletions test-workspace/tsc/passedFixtures/vue3/#5159/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script setup lang="ts">
import Child from './child.vue';
</script>

<template>
<Child as="h2" />
</template>