Subscribe on changes!

defineComponent had type error

avatar
Jun 20th 2023

Vue version

3.3.4

Link to minimal reproduction

https://www.typescriptlang.org/play?ssl=7&ssc=2&pln=1&pc=1#code/JYWwDg9gTgLgBAbzgEwKYDNgDtUGELgQ5YwA0AFqQMqowCuY+JqAHmVQDYQwDOAKgE8wqOAF846KATgAiAG51UMgFABjIj3j5wAXjSYc2yMRgAKZXEtwA9NZhCRqKFKgWrpsFLA8AXAlGkqjAsPjT0jEQwrDAAPADaALrUXLyCwjEI6BAQPppQ2ADmogB8xQCUOsUIblZWULR0UFhwphXF5KYA5MjAcp1lNWLKZUA

Steps to reproduce

//

What is expected?

//type error
defineComponent(
    (props:{},ctx:SetupContext<[],SlotsType<{foo:string}>>)=>{
        return ()=>h('div')
    }
)

What is actually happening?

Type '{ attrs: Data; slots: Readonly<InternalSlots>; emit: (event: string, ...args: any[]) => void; expose: (exposed?: Record<string, any> | undefined) => void; }' is not assignable to type '{ attrs: Data; slots: Readonly<{ foo: Slot<string>; }>; emit: (event: never, ...args: any[]) => void; expose: (exposed?: Record<string, any> | undefined) => void; }'.

System Info

No response

Any additional comments?

No response

avatar
Feb 12th 2024

Closing this, explanation here

TLDR: This is just type usage but there's need for the runtime information to also be provided, since the usage from the docs is not being followed, this is not an error or bug.