Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types(defineComponent): DefineComponent should infer correct types when assigning to Component #5948

Closed
pikax opened this issue May 18, 2022 · 0 comments · Fixed by #5949
Closed

Comments

@pikax
Copy link
Member

pikax commented May 18, 2022

Link to minimal reproduction

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYQuCA7AphmAaOAEywDNhtV1tc4BfOEqNOAcgDcBXLFgWACh+xAMYAbAIZQsDDhiExgmOFgAeYLHIAqATzUAeDQD4AFGzEiuALjgaAlFbYRghfvxFZ4QtJGowrlbzgw-J5UgXAAvESk5Fj+mIFGCPxwKXBgTGAAzlZJfKn5cDBYmb5wAMowUOQA5njJqbR1eamZ7hxgRgD6BEhiMJWZBJkiEDCZdDaI9QVwAPSzcAACYwC0Kmpya1BMUHCZABYQHCKEcBijcABGUmIYWtMF6+ow2noA2gC6xn0DNg-58yWqyemyw22ge0Ox1O53g1zgt3uzRmIJeOiwuk+xmGo0yf2RdH4tBsQA

Steps to reproduce

let component: Component
component = defineComponent({
    props: {
        test: String,
    },
    setup(_, { attrs, slots }) {
        // @ts-expect-error should not be any
        expectType<[]>(attrs)
        // @ts-expect-error should not be any
        expectType<[]>(slots)
    }
})

What is expected?

defineComponent to infer the options correctly

What is actually happening?

RawOptions is breaking the inference because defaults to {}

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 11.13 GB / 63.94 GB
  Binaries:
    Node: 16.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.13 - C:\Program Files\nodejs\yarn.CMD
    npm: 7.24.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (101.0.1210.47)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    vue: workspace:* => 3.2.34-beta.1

Any additional comments?

vuejs/test-utils#1510

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant