JustCurious
JustCurious

Reputation: 830

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?

Upvotes: 3

Views: 3196

Answers (1)

Nathan Friend
Nathan Friend

Reputation: 12814

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

Upvotes: 5

Related Questions