tsx accepts Typescript single line inputs, but not multiline inputs, unlike ts-node.
ts-node:
username@localhost:~ $ ts-node
> function stringify(num: number): string { return "" + num; }
undefined
> function unstringify(num: string): number {
... return +num;
... }
undefined
>
tsx:
username@localhost:~ $ tsx
Welcome to Node.js v21.7.1.
Type ".help" for more information.
> function stringify(num: number): string { return "" + num; }
undefined
> function unstringify(num: string): number {
function unstringify(num: string): number {
^
Uncaught SyntaxError: Unexpected token ':'
>
This issue is not reproducible with the StackBlitz template provided, since it involves interactive use of the CLI rather than running a file.
Contributions
[ ] I will open a pull request for this issue
[ ] I will support the work financially (any amount helps)
Acknowledgements
Minimal reproduction URL
Not applicable as a file
Version
v4.7.1
Node.js version
v21.7.1
Package manager
N/A
Operating system
Windows
Problem & expected behavior (under 200 words)
tsx
accepts Typescript single line inputs, but not multiline inputs, unlikets-node
.ts-node
:tsx
:This issue is not reproducible with the StackBlitz template provided, since it involves interactive use of the CLI rather than running a file.
Contributions