[SOLVED] How can I specify boolean (true/false) options for TypeScript compiler

Issue

I’m using:

$ tsc --version
Version 2.0.8

and trying to pass --experimentalDecorators option to tsc like this:

$ tsc --experimentalDecorators true greeter.ts
//error TS6053: File 'true.ts' not found.

and like this

$ tsc greeter.ts --experimentalDecorators true
//error TS6053: File 'true.ts' not found.

and like this

$ tsc greeter.ts --experimentalDecorators=true
// error TS5023: Unknown compiler option 'experimentaldecorators=true'.

but no luck. What’s the correct way to pass options to tsc?

Solution

Boolean flags are false by default so you don’t need to specify a value along with the flag. You only need to include the flag when you want to change it from false to true.

Remove true:

tsc --experimentalDecorators greeter.ts

For compiler options that expect a string, the value immediately following the argument specifies the argument’s value. For example:

tsc --module system greeter.ts

For compiler options that expect an array of strings, the individual string values should be separated by commas:

tsc --lib es5,es6 greeter.ts

The compiler assumes the value passed in is a filename if the value does not match an argument name or is not in the place of an expected argument value.

Answered By – David Sherret

Answer Checked By – David Goodson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *