Skip to content

Prop validator breaks composition api Setup props object when using typescript #3000

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

Closed
arthurvasconcelos opened this issue Jan 13, 2021 · 1 comment

Comments

@arthurvasconcelos
Copy link

Version

3.0.0

Reproduction link

https://codesandbox.io/s/epic-cohen-ddy3e?file=/src/components/TestProps.vue

Steps to reproduce

Removing the validator on the "msg" prop will make the error vanish.

What is expected?

To have access to the prop in the Setup method.

What is actually happening?

Property 'msg' does not exist on type 'Readonly<{ [x: number]: string; } & { length?: number | undefined; toString?: string | undefined; toLocaleString?: string | undefined; concat?: string[] | undefined; join?: string | undefined; slice?: string[] | undefined; ... 16 more ...; flat?: unknown[] | undefined; }> | Readonly<...>'.
  Property 'msg' does not exist on type 'Readonly<{ [x: number]: string; } & { length?: number | undefined; toString?: string | undefined; toLocaleString?: string | undefined; concat?: string[] | undefined; join?: string | undefined; slice?: string[] | undefined; ... 16 more ...; flat?: unknown[] | undefined; }>'.

Locally this is the complete error output:

ERROR in src/components/TestProps.vue:27:23
TS2339: Property 'msg' does not exist on type 'Readonly<{ [x: number]: string; } & { length?: number | undefined; toString?: string | undefined; toLocaleString?: string | undefined; concat?: string[] | undefined; join?: string | undefined; slice?: string[] | undefined; ... 16 more ...; flat?: unknown[] | undefined; }> | Readonly<...>'.
  Property 'msg' does not exist on type 'Readonly<{ [x: number]: string; } & { length?: number | undefined; toString?: string | undefined; toLocaleString?: string | undefined; concat?: string[] | undefined; join?: string | undefined; slice?: string[] | undefined; ... 16 more ...; flat?: unknown[] | undefined; }>'.
    25 |   },
    26 |   setup(props) {
  > 27 |     console.log(props.msg);
       |                       ^^^
    28 |   }
    29 | });
    30 | </script>
@posva
Copy link
Member

posva commented Jan 13, 2021

Duplicate of #2474

@posva posva marked this as a duplicate of #2474 Jan 13, 2021
@posva posva closed this as completed Jan 13, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants