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

Be able to import types when using NodeNext TypeScript module resolution #1703

Closed
ChocolateLoverRaj opened this issue Mar 16, 2022 · 8 comments

Comments

@ChocolateLoverRaj
Copy link
Contributor

I'm making an npm package which uses ora. To use ora, I switched to NodeNext module resolution. After doing that, the type checking for commander stopped working. I think package.json needs to be updated to be compatible with NodeNext module resolution.

Here is the guide to by the author of ora: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c.
Here is some related TypeScript documentation: https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#esm-nodejs

@ChocolateLoverRaj
Copy link
Contributor Author

I found out how to make it work: I copied typings/index.d.ts to esm.d.mts

@shadowspawn
Copy link
Collaborator

How are you importing Commander into your source file? e.g.

import { Command } from 'commander';

@ChocolateLoverRaj
Copy link
Contributor Author

Creating esm.d.mts with this also works:

export * from './typings/index.js'

@ChocolateLoverRaj
Copy link
Contributor Author

@shadowspawn I'm importing it exactly like that

@shadowspawn
Copy link
Collaborator

shadowspawn commented Mar 16, 2022

@ChocolateLoverRaj
Copy link
Contributor Author

@shadowspawn Should I make a PR adding the "types"?

@shadowspawn
Copy link
Collaborator

Yes, if you like. I was about to myself, but give you first option. 😄

@shadowspawn shadowspawn added pending release Merged into a branch for a future release, but not released yet enhancement labels Mar 18, 2022
@shadowspawn shadowspawn removed the pending release Merged into a branch for a future release, but not released yet label Apr 15, 2022
@shadowspawn
Copy link
Collaborator

Fixed in Commander v9.2.0

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

No branches or pull requests

2 participants