In props default function value does not get type checked
Version
3.2.23
Reproduction link
Steps to reproduce
yarn install
yarn run vue-tsc --noEmit
What is expected?
In src/App.vue
default
function value for prop user
should be flagged as error, since '123' does not correspond to type User
What is actually happening?
vue-tsc does not report any typescript errors
As I understood by looking into PropOptions
and DefaultFactory
type definitions in vue, return value of default
function is intended to be strictly type checked, but I am new to typescript so I may be missing something.
In setup
function props.user
is always recognised as User
by my editor independent of the actual return type of default
function.
UPDATE: I updated the example repo by changing User
property name
to nickname
since every function has a name
property. Issue persists.
I investigated a little further and found out that source of the issue is PropOptions
with its property default?: D | DefaultFactory<D> | null | undefined | object;
, specifically object
type which covers every possible non-primitive value, including any function.