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

Toggle JSX namespace based on svelte vs svelte-native #351

Merged
merged 3 commits into from
Jul 25, 2020

Conversation

halfnelson
Copy link
Contributor

This brings Svelte Native support to language tools.
Since svelte and svelte-native have different intrinsic elements, it was essential to namespace them (JSX -> svelte.JSX)
The namespace is chosen by typescript based on the jsxFactory compiler option. I have changed this to be either svelte.createElement or svelteNative.createElement to select either svelte.JSX or svelteNative.JSX namespace.

The code tries to detect svelte-native by resolving the package. The namespace can be forced by providing jsxFactory compiler option in your tsconfig.

I had to change a couple of tests to handle the new test folder I added, and to handle the namespace change.
I think the language server will work with old versions of svelte2tsx (as the namespace falls back to JSX) but an old language-server release against a new svelte2tsx will probably show unwanted TS errors

@dummdidumm
Copy link
Member

Great stuff! Nice side effect: This also fixes #228, no more clashes with react types because it's now regarded as a different factory.

@dummdidumm dummdidumm merged commit d15939c into sveltejs:master Jul 25, 2020
dummdidumm added a commit that referenced this pull request Jul 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants