Skip to content

Bug: Type-check doesn't work properly for variables declared in script setup components #1866

@gbyesiltas

Description

@gbyesiltas

Describe the bug
Trying to access a variable declared in a component written with script setup results in a type error

Property 'someVariable' does not exist on type '{ $: ComponentInternalInstance; $data: {}; $props: Partial<{ errors: string[]; }> & Omit<Readonly<ExtractPropTypes<{ action: { type: PropType<"Update" | "Create">; required: true; }; ... 5 more ...; isLoading: { ...; }; }>> & ... 5 more ... & ComponentCustomProps, "errors">; ... 10 more ...; $watch<T extends string ...'.

To Reproduce

  1. Create a component with script setup and declare a variable inside it
  2. Write a test where you are trying to access that variable with wrapper.vm.someVariable
  3. The type-check will give an error similar to the one above

Expected behavior
The variable accesses to work without typing errors

Related information:

  • @vue/test-utils version: 2.2.3
  • Vue version: 3.2.45
  • node version: 16.17.0
  • npm (or yarn) version: 9.1.1

Additional context
The tests do pass, but typescript isn't happy

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions