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

A crazy issue using svelte2dts through svelte2tsx #910

Open
frederikhors opened this issue Mar 23, 2021 · 4 comments
Open

A crazy issue using svelte2dts through svelte2tsx #910

frederikhors opened this issue Mar 23, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@frederikhors
Copy link
Contributor

frederikhors commented Mar 23, 2021

Describe the bug

I have this component:

<script lang="ts">
  export let one = false;
  export let disabled = false;
  export let two = false;
  export let three = "";
  export let four = false;
  export let fivefive = false;
</script>

<div {disabled}>Hello!</div>

if I use svelte2dts to create it's declaration types it works but I have this error using it:

Argument of type 'string' is not assignable to parameter of type 'never'. ts(2345)

image

If instead I rename this line:

- export let fivefive = false;
+ export let five = false;

it works! It's crazy! I know!

image

I think svelte2dts is using svelte2tsx for conversion, right?

To Reproduce

Component REPO: https://github.com/frederikhors/svslte2tsx-issue-on-never

- clone it
- npm install
- npm run build
- npm link
- cd your svelte ts project
- npm link svslte2tsx-issue-on-never
- use it like below
- open VSCode
- TADA the problem!

Use it like this:

<Test on:click={() => window.location.reload()}>Reload</Test>

Expected behavior

I do not understand with in the first case this is what I got in VSCode for on:

(method) Svelte2TsxComponent<{ one?: boolean; disabled?: boolean; two?: boolean; three?: string; four?: boolean; fivefive?: boolean; }, {}, {}>.$on<never>(event: never, handler: (e: never) => any): () => void

and in the second case I get:

(method) Svelte2TsxComponent<{ one?: boolean; disabled?: boolean; two?: boolean; three?: string; four?: boolean; five?: boolean; }, { [evt: string]: CustomEvent<any>; }, {}>.$on<"click">(event: "click", handler: (e: CustomEvent<any>) => any): () => void

System (please complete the following information):

  • OS: Windows 10
  • IDE: VSCode
  • Plugin/Package: svelte2dts through svelte2tsx
@dummdidumm
Copy link
Member

Yes, svelte2dts uses svelte2tsx. I have to check why this would make a difference. It should throw a type error in both cases because you don't forward the click event in Test.svelte, on:click will therefore never fire.

@dummdidumm
Copy link
Member

I investigated this a little and I really don't know what's causing this. My current guess is that this is some obscure TypeScript bug which occurs when there is a certain amount of props with a certain length.

@frederikhors
Copy link
Contributor Author

Oh my! Should we open some kind of issue on typescript repo?

@dummdidumm
Copy link
Member

Not yet, I'll try to narrow this down more to get a minimum reproducible independent of svelte2dts

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

2 participants