La Gregance
La Gregance

Reputation: 371

How to use ts-node regardless of errors?

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 ;)

Upvotes: 36

Views: 27236

Answers (4)

basarat
basarat

Reputation: 275917

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

ts-node -T someFile.ts

References

Upvotes: 7

Alexey Volkov
Alexey Volkov

Reputation: 1082

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.

Upvotes: 0

Evert
Evert

Reputation: 99533

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.

Upvotes: 55

justcodin
justcodin

Reputation: 1013

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.

Upvotes: 9

Related Questions