Skip to content
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

fix: use definition from defineProps if possible #3838

Open
wants to merge 4 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions package.json
Expand Up @@ -27,5 +27,14 @@
"typescript": "latest",
"vite": "latest",
"vitest": "latest"
},
"pnpm": {
"overrides": {
"@vue/runtime-dom": "alpha",
"@vue/shared": "alpha",
"@vue/compiler-dom": "alpha",
"@vue/compiler-sfc": "alpha",
"vue": "alpha"
}
Comment on lines +31 to +38
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't doing overrides at this level also affect/break vue 2 tests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not affect Vue 2 tests. Since this PR will only be merged when Vue 3.5 is released, this json section will be removed before merging.

}
}
162 changes: 75 additions & 87 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions test-workspace/tsc/vue3/#3779/main.vue
@@ -0,0 +1,10 @@
<script setup lang="ts">
import { exactType } from '../../shared';
defineProps<{
optionalBoolean?: boolean;
}>();
</script>

<template>
<h1>{{ exactType(optionalBoolean, {} as boolean | undefined) }}</h1>
</template>
10 changes: 10 additions & 0 deletions test-workspace/tsc/vue3/#3779/named.vue
@@ -0,0 +1,10 @@
<script setup lang="ts">
import { exactType } from '../../shared';
const props = defineProps<{
optionalBoolean?: boolean;
}>();
</script>

<template>
<h1>{{ exactType(optionalBoolean, true as boolean) }}</h1>
</template>
19 changes: 19 additions & 0 deletions test-workspace/tsc/vue3/#3820/main.vue
@@ -0,0 +1,19 @@
<script setup lang="ts" generic="T extends { name: string }">
const props = defineProps<{
one: T;
all: Array<T>;
}>();
</script>

<template>
<div>
<!-- incorrect inference -->
<div>{{ one.name }}</div>
<!-- correct inference -->
<div>{{ props.one.name }}</div>
<ul>
<!-- correct inference -->
<li v-for="el in all">{{ el.name }}</li>
</ul>
</div>
</template>