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

Support typescript natively #929

Closed
ziimakc opened this issue Nov 2, 2024 · 7 comments · Fixed by #930
Closed

Support typescript natively #929

ziimakc opened this issue Nov 2, 2024 · 7 comments · Fixed by #930
Labels

Comments

@ziimakc
Copy link

ziimakc commented Nov 2, 2024

Allow to run typescript files natively.

The flag --experimental-strip-types enables Node.js to run TypeScript files. https://nodejs.org/api/typescript.html

Flag is available in current LTS node v22.

@ziimakc ziimakc changed the title Support typescript Support typescript natively Nov 2, 2024
@antongolub
Copy link
Collaborator

Hey @ziimakc,

Hmm... This should work:

"test:smoke:strip-types": "node --experimental-strip-types test/smoke/ts.test.ts",

What's your use case?

@antongolub
Copy link
Collaborator

Anyway, it seems reasonable provide overriding the default ext (.mjs) in some cases.

@antonmedv
Copy link
Collaborator

It will be cool if zx have support for ts without any other:

npx zx script.ts

zx can spawn a node with --experimental-strip-types on it's own.

@antongolub
Copy link
Collaborator

antongolub commented Nov 3, 2024

npx accepts node flags via NODE_OPTIONS for its own internal spawn: NODE_OPTIONS='--experimental-strip-types' npx zx. So we can avoid extra node > node process init.

@ziimakc
Copy link
Author

ziimakc commented Nov 3, 2024

@antongolub I just want to run typescript files to ensure scripts are correct.

@antongolub
Copy link
Collaborator

In this case tsc is required to check (not only strip) types.

@ziimakc
Copy link
Author

ziimakc commented Nov 4, 2024

@antongolub yes, tsc to check types and --experimental-strip-types to run the file

"test:smoke:strip-types": "node --experimental-strip-types test/smoke/ts.test.ts"

Indeed, I was confused a bit because of zx explicit imports are required then.

@ziimakc ziimakc closed this as completed Nov 4, 2024
antongolub added a commit to antongolub/zx that referenced this issue Nov 8, 2024
antongolub added a commit to antongolub/zx that referenced this issue Nov 8, 2024
antonmedv pushed a commit that referenced this issue Nov 8, 2024
* feat(cli): allow to override default script extension

closes #929

* test: up size-limit

* docs: mention `--ext` flag in man

* refactor: handle extensions without dot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants