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

fix: use js extensions instead of ts in imports #1374

Merged
merged 1 commit into from
Nov 4, 2024
Merged

Conversation

jorenbroekema
Copy link
Collaborator

@jorenbroekema jorenbroekema commented Oct 28, 2024

Issue #, if available:
closes #1371

Description of changes:

Generally speaking TypeScript expects .js extensions for imports because the compiled output is .js. In the future TS might release a new feature allowing .ts extensions, but currently under NodeNext moduleResolution, .js is the way to go for files that actually compile to JS.

That said, in JSDocs annotated type-only imports we should use .d.ts extension because we only emit declaration files for these, so the compiled output is just .d.ts files.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jorenbroekema jorenbroekema requested a review from a team as a code owner October 28, 2024 09:20
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-1374.d16eby4ekpss5y.amplifyapp.com

@@ -3,8 +3,6 @@
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
// Allow importing TypeScript files using their native extension (.ts(x)).
"allowImportingTsExtensions": true,
Copy link
Collaborator Author

@jorenbroekema jorenbroekema Oct 28, 2024

Choose a reason for hiding this comment

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

In latest typescript this only works with emitDeclarationOnly (we could also just set that to true), but imo this flag is kinda tech debt anyways because it relies on bundler tool to resolve the import paths, and we actually want to stay bundleless.

@zacowan
Copy link

zacowan commented Oct 30, 2024

This closes #1371 🥂

@jorenbroekema jorenbroekema enabled auto-merge (squash) October 31, 2024 08:20
@jorenbroekema jorenbroekema merged commit ef61399 into main Nov 4, 2024
5 checks passed
@jorenbroekema jorenbroekema deleted the js-extensions branch November 4, 2024 18:35
jorenbroekema added a commit that referenced this pull request Nov 7, 2024
dbanksdesign pushed a commit that referenced this pull request Nov 7, 2024
tkgroot pushed a commit to tkgroot/style-dictionary that referenced this pull request Dec 9, 2024
tkgroot pushed a commit to tkgroot/style-dictionary that referenced this pull request Dec 9, 2024
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.

Types Resolve as any for TypeScript<5.x.x
3 participants