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

[New] TypeScript config: add .cts and .mts extensions #2851

Merged
merged 1 commit into from Aug 19, 2023
Merged

[New] TypeScript config: add .cts and .mts extensions #2851

merged 1 commit into from Aug 19, 2023

Conversation

Zamiell
Copy link
Contributor

@Zamiell Zamiell commented Aug 7, 2023

This PR is pretty self explanatory.
.cts and .mts are common file extensions used in projects that are not fully CJS or not fully ESM.
So I added those to the config.
I also fixed some of the grammar and made the comments wrap to 100 characters.

config/typescript.js Outdated Show resolved Hide resolved
config/typescript.js Outdated Show resolved Hide resolved
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Seems reasonable.

@ljharb
Copy link
Member

ljharb commented Aug 17, 2023

I'll rebase and land this once we get more travis-ci credits.

@ljharb ljharb changed the title feat: add .cts and .mts extensions to typescript config [New] TypeScript config: add .cts and .mts extensions Aug 18, 2023
@ljharb ljharb merged commit 4d32d68 into import-js:main Aug 19, 2023
162 of 163 checks passed
@Zamiell Zamiell deleted the typescript-exts branch August 19, 2023 19:03
@JounQin
Copy link
Collaborator

JounQin commented Jan 17, 2024

AFAIK, .cjs/.cts and .mjs/.mts must be used specifically, what means 'import/extensions': allExtensions is wrong configed now. import './x' should not try to resolve ./x.cts/.x.mts at all.

@ljharb
Copy link
Member

ljharb commented Jan 17, 2024

@JounQin is that always? or only when verbatimModuleSyntax: true?

@JounQin
Copy link
Collaborator

JounQin commented Jan 17, 2024

@ljharb I don't think it's the same thing here.

@ljharb
Copy link
Member

ljharb commented Jan 17, 2024

With TS transpiled to CJS, i would expect extensions to be looked up.

@JounQin
Copy link
Collaborator

JounQin commented Jan 17, 2024

No, the output extension will not change, although this feature is requested for a long time. TypeScript focuses on typings with correct module resolution, but never changes user's source codes.

@ljharb
Copy link
Member

ljharb commented Jan 17, 2024

Gotcha. Does that mean this PR should be reverted? If it's not that straightforward, a PR to fix it would be appreciated.

@JounQin
Copy link
Collaborator

JounQin commented Jan 17, 2024

Yes, it must be reverted, I'll raise a PR tomorrow.

Hope you can pin me with TypeScript related changes next time. 🩷

@ljharb
Copy link
Member

ljharb commented Jan 17, 2024

That's very reasonable; will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants