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

slotProps Typescript #1635

Closed
MichaelVonB opened this issue Oct 4, 2021 · 9 comments
Closed

slotProps Typescript #1635

MichaelVonB opened this issue Oct 4, 2021 · 9 comments

Comments

@MichaelVonB
Copy link

MichaelVonB commented Oct 4, 2021

[x] bug report

Current behavior

I am using typescript with vue-tsc --noEmit && vite build
<Timeline :value="stateList" align="top" layout="horizontal">
        <template #content="slotProps">
          <h5>{{ slotProps.item }}</h5>
        </template>
...
</Timeline>

But I am getting the error
Property 'item' does not exist on type 'VNode<RendererNode, RendererElement, { [key: string]: any; }>[]'.

{{ slotProps.item }}

Expected behavior
Types should be declared

Minimal reproduction of the problem with instructions

<Timeline :value="stateList" align="top" layout="horizontal">
        <template #content="slotProps">
          <h5>{{ slotProps.item }}</h5>
        </template>
...
</Timeline>

https://codesandbox.io/s/pedantic-boyd-0mqx2?file=/src/App.vue
use Volar in Vscode or try to build using vue-tsc --no-emit and vite-build

@tugcekucukoglu
Copy link
Member

tugcekucukoglu commented Oct 4, 2021

Could you provide a codesandbox sample. I could not replicate it. https://codesandbox.io/s/dark-haze-cg49t?file=/src/App.vue

@MichaelVonB
Copy link
Author

MichaelVonB commented Oct 4, 2021

updated my question and provied a codesandbox. Notice that the code works its just that volar or vue-tsc does not accept it as there is something wrong with type declarations

@tugcekucukoglu tugcekucukoglu self-assigned this Oct 4, 2021
@tugcekucukoglu
Copy link
Member

Could you tell us your environment? With PrimeVue 3.7.2, I didn't get any error.

@MichaelVonB
Copy link
Author

Seems like the build error is gone. Now its just a warning from Volar in VSCode

@tugcekucukoglu tugcekucukoglu removed their assignment Oct 4, 2021
@tugcekucukoglu
Copy link
Member

I didn't get any error from Volar in VSC. If you have a problem with build, please reopen this issue.

@johnsoncodehk
Copy link

$slots: {
content: VNode[];
opposite: VNode[];
marker: VNode[];
connector: VNode[];
}

Component $slots type definition incorrect, it should be:

declare class Timeline {
    $props: TimelineProps;
    $slots: {
        content: (binds: ContentSlotBindings) => VNode[];
        opposite: (binds: OppositeSlotBindings) => VNode[];
        marker: (binds: MarkerSlotBindings) => VNode[];
        connector: (binds: ConnectorSlotBindings) => VNode[];
    }
}

@tugcekucukoglu
Copy link
Member

Fixed for the next version. #1695

@m-v-peter
Copy link

this issue still exists in 3.10.0

@TBruegg
Copy link

TBruegg commented Jan 4, 2022

I also encountered this issue when using the #header slot of TabPanel in 3.10.0. I therefore created #1943.

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

No branches or pull requests

5 participants