27

I've got some trouble with ts-node when I develop.

I want to test something, so as you know, comment is my best friend. But with ts-node I've got this error :

'foo' is declared but its value is never read

But I don't want to comment all my unused variables because theses variables are in fact useful for the code after testing.

So, is there a solution like ts-node --please-let-me-work to ignore these error ?

Thanks ;)

La Gregance
  • 271
  • 1
  • 3
  • 5

4 Answers4

41

ts-node has a --transpile-only (or -T) argument. It will ignore all type errors and just build your project.

My 2022 suggestion for this to set up esbuild instead. Not a plug and play experience, but extremely fast. We use esbuild for (constant) building during development, and rely on other tools to report type errors.

Evert
  • 93,428
  • 18
  • 118
  • 189
9

If you use ts-node, you can use this alternative :

$ ts-node-transpile-only filename.ts

It will run the typescript file without checking errors.

justcodin
  • 857
  • 7
  • 17
  • Do you mean to use this ubuntu [package](https://manpages.ubuntu.com/manpages/jammy/man1/ts-node-transpile-only.1.html)? – Klesun May 08 '23 at 19:28
7

Use -T or --transpileOnly and make sure its passed in before the file name. So:

ts-node -T someFile.ts

References

basarat
  • 261,912
  • 58
  • 460
  • 511
0

ts-node --logError helped me. Now, instead of terminating the app, it just shows an error.

https://www.npmjs.com/package/ts-node#logerror

Though, it works only for type checking and other "light" errors. If there is a syntax error or something that ts-node really can't process, it will fail.

Alexey Volkov
  • 978
  • 6
  • 4