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

Migration to TypeScript: JavaScript components have types of props set to "undefined" instead of "any" when used from TypeScript #697

Closed
angryziber opened this issue Dec 6, 2020 · 1 comment
Assignees
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@angryziber
Copy link

Describe the bug
I have added svelte-preprocess to a rather large existing project and started converting components one-by-one to lang="ts".
I also have added svelte-check to check for errors.

Unfortunately, converting to ts works only for lowest level components first, because you cannot pass any properties to a js component, which props are all indentified as "undefined". If you convert imported components to ts, even without specifying the type, then props are correctly identified as "any" and everything works.

Is the problem with svelte2tsx or a similar tool? I don't know if it's used behind-the-scenes by svelte-check or not.

To Reproduce
Use a js component with properties from a ts component, then build the project with npm run build

Expected behavior
svelte-check should not emit any errors for existing properties, resulting in successful build.

System (please complete the following information):

  • OS: Linux (not relevant)
  • IDE: Intellij (not relevant)
  • Plugin/Package: svelte-check is used directly from snowpack

Additional context
Gradual migration of svelte components to TypeScript (the rest of code is TypeScript already)

@angryziber angryziber added the bug Something isn't working label Dec 6, 2020
@dummdidumm
Copy link
Member

This only seems to be the case when strict mode is turned on in the tsconfig.json and when props have no fallback value.

@dummdidumm dummdidumm self-assigned this Dec 7, 2020
dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Dec 7, 2020
Fall back to any-type when a prop has no fallback value in JS
sveltejs#697
dummdidumm added a commit that referenced this issue Dec 8, 2020
Fall back to any-type when a prop has no fallback value in JS
#697
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

2 participants