-
-
Notifications
You must be signed in to change notification settings - Fork 532
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
Suggestion: always run ".ts" files. Don't ever say .ts is unknown. #1967
Comments
I even lean towards saying that when running a ts file ts-node should automatically apply the correct settings (type: module in package.json, module: esnext in tsconfig.ts) if not already properly given. |
Hello! By default, If you need to change between CJS/ESM - try: For ESM
For CommonJS
|
Thanks @SeryiBaran but nobody is asking for instructions on how to use ESM. This is a feature request to use sensible defaults automatically to run TS files (including using ESM). |
I wholeheartedly agree. Why do I need to set up a By normal, in the year 2023, I mean:
For example:
and it should run. The hoops you have to jump through if you haven't yet used ts-node:
This all, to run a simple TypeScript script. Ah, and you still have the file extension |
test:mocha-ts* are not usable per several issues with ts-node (10.9.2 or earlier): - TypeStrong/ts-node#2000 no tsconfig extends multiple files support - TypeStrong/ts-node#1967 lack of .ts + ESM understanding - failure to resolve .js extensions using CommonJS
- fix explicit paths for full ESM - address lodash imports - various corrections from more strict tsc options with tests including testing LZ4PropertyTree not previously tested. ## remove mocha-ts scripts test:mocha-ts* are not usable per several issues with ts-node (10.9.2 or earlier): - TypeStrong/ts-node#2000 no tsconfig extends multiple files support - TypeStrong/ts-node#1967 lack of .ts + ESM understanding - failure to resolve .js extensions using CommonJS --------- Co-authored-by: Sonali Deshpande <48232592+sonalideshpandemsft@users.noreply.github.com> Co-authored-by: Jason Hartman <jasonha@microsoft.com>
Hi @michaelschufi, I would like to ask for your permission to print your awesome comment, so I can put it on the wall? Potentially I will print a t-shirt too. Thanks. |
@sangdth |
Desired Behavior
There's a whole bunch of closed tickets, online discussion, workarounds, etc. for this:
Regardless of the contents of package.json, the
ERR_UNKNOWN_FILE_EXTENSION
is not a logical error for a program whose only purpose is to run TypeScript files.Thanks for understanding the frustration of the many people that have tried to use ts-node to run a
.ts
file and been told this isn't possible.Is this request related to a problem?
Additional context
Other tools like
esrun
have been created precisely because of this issue. Rather than close every ticket with 'user error' it would be better if ts-node ran ts files, just like python runs python files and ruby runs ruby files and bash runs bash files.The text was updated successfully, but these errors were encountered: