Subscribe on changes!

Ref

avatar
Sep 20th 2021

Version

3.2.12

Reproduction link

new-issue.vuejs.org/

Steps to reproduce

export interface BlogContent {
    id: string;
    title: string;
    contentMd: string;
    typeId: string;
    userId: string;
}
  const blogContent = ref<BlogContent>();

What is expected?

i would like to get the blogContent'type is only 'Ref< BlogContent>', but it is not

What is actually happening?

blogContent'type is "const blogContent: Ref<BlogContent | undefined>" and i will get the mistake is "Object is possibly 'undefined'.Vetur(2532)"

avatar
Sep 20th 2021

You are saying it's aways an object but initializing it with an undefined value, that's just wrong code.