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

Provide a command-line tsc flag for specifying type in package.json #54876

Closed
not-my-profile opened this issue Jul 4, 2023 · 5 comments
Closed

Comments

@not-my-profile
Copy link

To quickly check if some package properly provides its types under node16 from ESM it would be convenient if you could specify "node16 & ESM" solely on the command-line, but currently that does not appear to be possible since you apparently have to put "type": "module" in the package.json file.

I also tried using --moduleDetection force but that didn't have the same effect as "type": "module" in package.json either.

@fatcerberus
Copy link

This is a Node.js runtime requirement, so any option to override it would essentially be lying to TS about the runtime environment, leading to runtime errors. It would do more harm than good, IMO.

@not-my-profile
Copy link
Author

Fair enough ... I still think the moduleDetection documentation should be clarified ... I guess it's only about the detection of other modules but not the detection of the current module?

@fatcerberus
Copy link

fatcerberus commented Jul 4, 2023

moduleDetection is about detecting module vs. not-module. All moduleDetection: "force" does it make TS detect files as modules (instead of old-style global scripts) even when they have no imports/exports. What kind of module it is (ESM vs. CommonJS) is a separate concern that is controlled by other options.

@not-my-profile
Copy link
Author

Ah I see, thanks for elaborating! I guess I was confused by "type": "module" in package.json only referring to ES modules.

@not-my-profile
Copy link
Author

Closing this since debugging node16 resolutions is probably rather an edge case and probably warrants dedicated tooling like @arethetypeswrong/cli.

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

No branches or pull requests

2 participants