Closed as not planned
Description
Vue version
3.2.37
Link to minimal reproduction
Steps to reproduce
// index.vue
<script lang="ts" setup>
import { ref } from 'vue';
import MyModal from './MyModal.vue';
// type error:Unsafe assignment of an `any` value
const modal1 = ref<InstanceType<typeof MyModal> | null>(null);
// open can get the correct type:(() => boolean) | undefined
// but lint error:Unsafe member access .value on an `any` value & Unsafe call of an `any` typed value
const openModal = () => {
modal1.value?.open(); // success
};
</script>
<template>
<header>
<img
alt="Vue logo"
class="logo"
src="https://cn.vuejs.org/images/logo.svg"
width="125"
height="125"
/>
<button @click="openModal">点击调用子组件方法</button>
<MyModal ref="modal1" />
<div class="wrapper">
<!-- <HelloWorld msg="You did it!"/> -->
<nav>
<!-- <RouterLink to="/">Home</RouterLink>
<RouterLink to="/about">About</RouterLink> -->
</nav>
<button>aa</button>
</div>
</header>
<!-- <RouterView/> -->
</template>
<style></style>
// MyModal.vue
<script lang="ts" setup>
import { ref } from 'vue';
const isContentShown = ref(false);
const open = () => (isContentShown.value = !isContentShown.value);
defineExpose({ open });
</script>
<template>
<div v-if="isContentShown">modal</div>
</template>
<style></style>
tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"baseUrl": ".",
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}
tsconfig.node.json
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
What is expected?
no lint error
What is actually happening?
lint error
System Info
No response
Any additional comments?
Volar ver:1.0.7