defineProps<T> partial object type inferred as 'unknown'
Vue version
latest 3.3.4 / 2.7.14
Link to minimal reproduction
Steps to reproduce
<script lang="ts" setup>
interface Option1 {
title?: string
description?: string
}
interface Option2 {
title: string
description?: string
}
defineProps<{
option1: Option1;
option2: Option2;
option3: Required<Option1>;
option4: Partial<Option2>;
}>()
</script>
<template>
<div>
{{ option1.title }} <!-- Property 'title' does not exist on type 'unknown'.ts(2339) -->
{{ option2.title }}
{{ option3.title }}
{{ option4.title }} <!-- Property 'title' does not exist on type 'unknown'.ts(2339) -->
</div>
</template>
What is expected?
Prop option1
inferred as object and property 'title' inferred as string | undefined.
What is actually happening?
Prop option
inferred as 'unknown',
Property 'title' does not exist on type 'unknown'
System Info
System:
OS: macOS 13.4.1
CPU: (10) arm64 Apple M1 Pro
Memory: 240.05 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 16.20.0 - ~/.nvm/versions/node/v16.20.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.20.0/bin/yarn
npm: 8.19.4 - ~/.nvm/versions/node/v16.20.0/bin/npm
pnpm: 7.13.4 - ~/.nvm/versions/node/v16.20.0/bin/pnpm
Browsers:
Edge: 116.0.1938.76
Safari: 16.5.2
Safari Technology Preview: 17.0
Any additional comments?
https://discord.com/channels/325477692906536972/331999220125138944/1148868108719767573
Any idea why vue playground fails?
@serialine Do you mean you are experiencing this issue on your machine? Could you please provide a reproduction repository?
@so1ve Yes on my machine.
I created a reproduction and found the cause of the problem.
it happens when "strict": false
in the tsconfig.json. but the minimal requirements condition "noImplicitThis": true
is configured.
@serialine Thanks for your reproduction. It would be great if you report this issue to https://github.com/vuejs/language-tools instead of this repo so we can track there.