Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run typeScript code without a tsconfig.json file?

I have written a code typeScript but when I tried executing(tsc filename.ts) it I got an error saying "Cannot find global type 'IterableIterator'". I checked for this on the net and found that the problem was because of the ES5 generators (Check here). I need to create a tsconfig.json file and include a target field in it.

I was wondering if there a way in which I could pass the generators in the command line itself and not make the tsconfig.json?

like image 517
JustCurious Avatar asked Jun 24 '26 15:06

JustCurious


1 Answers

Yes, all of the compilerOptions that are configurable through a tsconfig.json file are also available at the command line:

https://www.typescriptlang.org/docs/handbook/compiler-options.html

In your specific example, try:

tsc filename.ts --target es5 --downlevelIteration --lib esnext
like image 55
Nathan Friend Avatar answered Jun 27 '26 08:06

Nathan Friend



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!