Skip to content

defineComponent: exposing properties breaks Options API typings #14117

@serkodev

Description

@serkodev

Vue version

3.5.24

Link to minimal reproduction

https://www.typescriptlang.org/play/#code/JYWwDg9gTgLgBAbzgEwKYDNgDtUGELgQ5YwA0cUGcAvnOlAXAOQBuArqkwFBeoAekWCgwBDNgBt4aTDnyFiMABSIucOAGdUMNmEUBKFWrUBjIuvgh1AczgBeChmVMAFqnHiITOHoDcqo6ZY5nCWVgBMdg7oTgDu0OLIXr7+apTaUFiIIdbkoRHUfmrUpP6UWGhQ+oZGMM7A6gB0oYU1dY15LcX+-JCaAFxwANrMoV4Auly0yUA

Thanks to @johnsoncodehk

Steps to reproduce

  1. use defineComponent to define an Options API component with setup, data, props, methods, and computed, and have each option read something like this.dataValue.
  2. Add expose: ['setupValue'] to that component.
  3. the this inside other options loses access to the usual props/setup/data/methods.

What is expected?

Can access the properties with this inside the component even expose is defined

What is actually happening?

Cannot access the properties with this if not defined in expose

Any additional comments?

Related:
vuejs/language-tools#5069
vuejs/language-tools#5763
vuejs/language-tools#5758

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions