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

Use node16 in tsconfig.json #2052

Merged
merged 2 commits into from
Oct 11, 2023
Merged

Use node16 in tsconfig.json #2052

merged 2 commits into from
Oct 11, 2023

Conversation

timotheeguerin
Copy link
Member

@timotheeguerin timotheeguerin commented Oct 10, 2023

Use typespec recommended tsconfig setting https://microsoft.github.io/typespec/extending-typespec/basics#4-create-libts, this is needed to correctly support node exports.

Switch module and moduleResolution to use node16 to tell typescript that it should resolve modules following node 16+ exports

See this stackoverflow for details https://stackoverflow.com/questions/58990498/package-json-exports-field-not-working-with-typescript

Change in last release of typescript removed the typesVersions which was the legacy way of specifying the types for additional path. So this setting is required to work correctly with node exports

"module": "NodeNext",
"moduleResolution": "NodeNext",
"module": "node16",
"moduleResolution": "node16",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to this file shouldn't actually be needed if you prefer to stay to nodenext

@@ -5,8 +5,8 @@
"composite": true,
"lib": ["ES2019"],
"target": "es2019",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"module": "node16",
Copy link
Contributor

@MaryGao MaryGao Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change! The issue we found happens in dev version e.g "@azure-tools/typespec-azure-core": "0.35.0-dev.11" and see pr #2053. And in our main we use the stable version not dev one.

Can you also make a pr to apply your change in my test branch? So we could verify it works or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That change should happen regardless of the version of typespec that you are using. You might get into the same issue with other packages in the future. So I would just merge that if it is not causing any issues anyway. If there is more problem to the dev version then we can investigate further.

Copy link
Contributor

@MaryGao MaryGao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@timotheeguerin timotheeguerin merged commit ab0d41c into main Oct 11, 2023
28 checks passed
@timotheeguerin timotheeguerin deleted the tsconfig/node16 branch October 11, 2023 15:21
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