Skip to content

Can't type dynamic slot when using strict mode for typescript #2266

Closed
@kalvenschraut

Description

@kalvenschraut
Contributor

reproduction

Basically the issue is that with strict mode, typescript complains that string | number (type from keyof $slots) can't index the slots object that is inferred from the component you added it to. Not sure how to fix this specifically, if volar has to make a change or if there is a way I can get typescript to not error here.

Activity

johnsoncodehk

johnsoncodehk commented on Dec 30, 2022

@johnsoncodehk
Member

Just had a look, this appears to be a duplicate of #625.

kalvenschraut

kalvenschraut commented on Dec 30, 2022

@kalvenschraut
ContributorAuthor

Doesn't appear obvious to me that it is, but if you say so.

Is there a way to ignore/get around this type error? one only ones I have left before I can turn on strict mode

kalvenschraut

kalvenschraut commented on Dec 30, 2022

@kalvenschraut
ContributorAuthor

Tried something like the below, but receiving a different error.

image

kalvenschraut

kalvenschraut commented on Dec 30, 2022

@kalvenschraut
ContributorAuthor

Weird the error just went away after awhile, vue-tsc doesn't error so I guess this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @johnsoncodehk@kalvenschraut

        Issue actions

          Can't type dynamic slot when using strict mode for typescript · Issue #2266 · vuejs/language-tools