Skip to content

2.2.6 reports null errors with v-model erroneously #5226

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

Closed
Cherry opened this issue Mar 1, 2025 · 0 comments · Fixed by #5225
Closed

2.2.6 reports null errors with v-model erroneously #5226

Cherry opened this issue Mar 1, 2025 · 0 comments · Fixed by #5225
Labels
good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first 🔨 p3-minor-bug

Comments

@Cherry
Copy link

Cherry commented Mar 1, 2025

Vue - Official extension or vue-tsc version

vue-tsc 2.2.6

VSCode version

1.97.2

Vue version

3.5.13

TypeScript version

5.8.2

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 9.50 GB / 31.91 GB
  Binaries:
    Node: 22.13.1 - ~\AppData\Local\fnm_multishells\21004_1740841832056\node.EXE
    npm: 10.9.2 - ~\AppData\Local\fnm_multishells\21004_1740841832056\npm.CMD

package.json dependencies

{
	"devDependencies": {
		"typescript": "5.8.2",
		"vue": "3.5.13",
		"vue-tsc": "^2.2.6"
	}
}

Steps to reproduce

Clone https://github.com/Cherry/vue-tsc-null-repro and run npm test

OR:

  • Create basic component (another-component.vue):
<template>
	{{ foo }}
</template>

<script setup lang="ts">
// more work would go here to handle v-model
defineProps({
	foo: {
		type: String,
		default: '',
	},
})
</script>
  • Consume in example.vue:
<script setup lang="ts">
import inputExample from './another-component.vue';

type Foo = {
	name: string;
}
type Bar = {
	id: string;
	foo: Foo | null;
};

const example: Bar = {
	id: '1',
	foo: null,
};

</script>
<template>
	<div v-if="example.foo" >
		<inputExample v-model="example.foo.name" />
	</div>
</template>
  • Observe errors on <inputExample v-model="example.foo.name" /> line:
src/example.vue:20:26 - error TS18047: '__VLS_ctx.example.foo' is possibly 'null'.

What is expected?

No errors should occur as the null-ness of this was checked above in the v-if on a parent element.

What is actually happening?

Type errors such as src/example.vue:20:26 - error TS18047: '__VLS_ctx.example.foo' is possibly 'null'. are thrown.

Link to minimal reproduction

https://github.com/Cherry/vue-tsc-null-repro

Any additional comments?

I suspect this was introduced in #5214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first 🔨 p3-minor-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants