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

Svelte default props are conflicted between TypeScript's props type and useDefaultProps causing an unusable output #1472

Open
1 of 12 tasks
Th1nkK1D opened this issue Jun 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Th1nkK1D
Copy link

Th1nkK1D commented Jun 7, 2024

I am interested in helping provide a fix!

Yes

Which generators are impacted?

  • All
  • Angular
  • HTML
  • Preact
  • Qwik
  • React
  • React-Native
  • Solid
  • Stencil
  • Svelte
  • Vue
  • Web components

Reproduction case

https://mitosis.builder.io/playground/?code=JYWwDg9gTgLgBAbzgVwM4FMAi6BmBDZAGxgAUoIxU4BfOHckOAcgAEAjZYQgE3SgDpgEAPQhgMCKmComAbgBQ84ADsYffAGN0cMhSoJ5cOADc8hZOgD8ALjioYUFQHMF1RegAekWHF74i8DjIyhowQspwALIAngDCEOAQyuiqABRg5JS2upQAlIiGKBjY%2FsQ5qKkGRkam5ui2TAAW6ISEEEwANIXUuQqFUOgwyFARADzcwMYAfAgZevy1FtSjwhPTrkA

Expected Behaviour

If the default value is given in useDefaultProps, it should be used as the default value instead of undefined.

<script context="module" lang="ts">
  interface Props {
    value?: string;
  }
</script>

<script lang="ts">
  export let value: Props["value"] = "hello"; // <- Focus here
</script>

<div>{value}</div>

PS. Playground doesn't not support TypeScript yet.

Actual Behaviour

Both default values given in useDefaultProps and undefined from optional property declared in the props type with TypeScript show up. Make the code unusable because of invalid syntax.

<script context="module" lang="ts">
  interface Props {
    value?: string;
  }
</script>

<script lang="ts">
  export let value: Props["value"] = (undefined = "hello"); // <- Focus here
</script>

<div>{value}</div>

image

Additional Information

No response

@Th1nkK1D Th1nkK1D added the bug Something isn't working label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant