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

Support TypeScript "moduleResolution": "node16" #1522

Closed
JuanM04 opened this issue Jun 15, 2022 · 5 comments
Closed

Support TypeScript "moduleResolution": "node16" #1522

JuanM04 opened this issue Jun 15, 2022 · 5 comments
Labels
feature request New feature or request Fixed Fixed in master branch. Pending production release.

Comments

@JuanM04
Copy link

JuanM04 commented Jun 15, 2022

Description

In TypeScript 4.7, along the property "module": "node16" that enables ESM features in TypeScript, there are new values for the property "moduleResolution": "node16" and "nodenext". Both values allows importing from dependencies with package.json exports, imports, and self-referencing. Right now, this property is hard-coded to "node".

Proposed solution

The svelte-language-server shouldn't hard-code that property and instead read it from the tsconfig.json

Alternatives

No response

Additional Information, eg. Screenshots

No response

@dummdidumm dummdidumm added the feature request New feature or request label Jun 15, 2022
dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Jun 16, 2022
dummdidumm added a commit that referenced this issue Jun 18, 2022
#1522

- only force module/resolutionmode if not set to something valid by user
- TS plugin: add new param to ts resolver to fix diagnostics not appearing
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Jun 18, 2022
@dan-peterson
Copy link

Hey @dummdidumm does this update for the language server need to be manually published to npm? Eager to try it out, but noticed NPM is listing it as 0.14.28 / updated 16 days ago.

@dummdidumm
Copy link
Member

dummdidumm commented Jun 18, 2022

The fixed label means it's fixed on master but not released yet. when the issue is closed it's released. You could try it out yourself by building from source. the getting started instructions in the main readme if this repo should help with that

@dan-peterson
Copy link

Okay cool I tried it out but encountered an issue.

It seems to honor my module resolution settings now, and that fixes the issue importing from a module that uses the new exports field in package.json. The language server no longer reports the error: "Cannot find module x or its corresponding type declarations".

However, it seems to no longer understand svelte file imports.

The problem may be unrelated / out of the scope of svelte-language-server, or even an issue with how I built it locally, I'm not sure, but figured it was worth noting here.


As a base case I did a clean install of SvelteKit with the demo code and updated the tsconfig:

"moduleResolution": "node16",

Now in index.svelte the language server reports the error:

import Counter from '$lib/Counter.svelte';

Cannot find module '$lib/Counter.svelte' or its corresponding type declarations.

And dropping the alias didn't solve the issue:

import Counter from '../lib/Counter.svelte';

Cannot find module '../lib/Counter.svelte' or its corresponding type declarations.

Note that in all cases the svelte project builds and runs fine. It's just the language server that's reporting errors.

@dummdidumm dummdidumm removed the Fixed Fixed in master branch. Pending production release. label Jun 19, 2022
dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Jun 19, 2022
@dummdidumm
Copy link
Member

Thank you, not sure how that slipped through. Should be fixed now.

@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Jun 19, 2022
@dan-peterson
Copy link

Should be fixed now.

Confirmed on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

3 participants