-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
Typescript cannot see prop types with tsconfig JSX setting as "react" #1256
Comments
The reason is that we internally use JSX to represent a Svelte file's types to Typescript. There's currently a rewrite ongoing to get rid of this and other limitations. No ETA on that. |
@dummdidumm thanks for the info. Is there an issue for that, or any other way to track progress and help out? |
This is the PR that contains the rewrite: #1237 . Not much to do for now other than wait on this until it lands and then help out beta-test it. |
Goal: Get rid of a tsx-style transformation and simplify transformations along the way #1077 #1256 #1149 Advantages: - no messing with projects who use JSX for some other reason and then have conflicting JSX definitions - TS control flow easier to keep flowing - overall easier transformations of Svelte specific syntax like await, each etc. - better type inference in some cases, for example around svelte:component This includes: - rewriting the html2jsx part of svelte2tsx - adjusting the language server to the new transformation - adding a toggle to language-server and vs code extension to turn on the new transformation. Default "off" for now, with the plan to switch it to "on" and then removing the old transformation altogether - ensuring tests run with both new and old transformation - adjusting the TypeScript plugin. It uses the new transformation already now since it's not easily possible to add an option (on/off). Should be low-impact since TS doesn't need to know much about the contents of a Svelte file, only its public API Look at the PR of this commit to see more explanations with some of the entry points of the new transformation.
The most recent versions of the extension and
Please try it out, more info in #1352 |
Describe the bug
Typescript is unable to see the Type for Props when tsconfig.json has
compilerOptions.jsx
set to"react"
. The use case is a single webpack bundle which has mixed react and svelte. It doesn't seem possible (at least conveniently so) to have two separate tsconfig.json projects, whilst also being able to import from one to another and resolve the issue both for IDE and the webpack build.To Reproduce
Minimal reproduction repo at https://github.com/petemill/reproduce-svelte-types-react-jsx
tsconfig.json
note
jsx
propertyFor example a code snippet that is treated in a way you don't expect.
Expected behavior
Typescript should error with
Type 'number' is not assignable to type 'string'
. This is the case ifcompilerOptions.jsx
is changed to"preserve"
.System (please complete the following information):
The text was updated successfully, but these errors were encountered: