Appendix F. TSC Compiler Flags for Safety
Tip
For a complete list of available compiler flags, head over to the TypeScript Handbook website.
Each TypeScript release introduces new checks that you can enable to squeeze even more safety out of your code. Some of these flags—prefixed with strict—are included as part of the strict flag; or, you can opt into strict flags one at a time. Table F-1 lists the compiler flags related to safety that are available at the time of writing.
| Flag | Description |
|---|---|
|
Emit |
|
Don’t emit JavaScript when your code has type errors. |
|
Make sure that every |
|
Error when a variable’s type is inferred as |
|
Make sure that every code path in every function explicitly returns. See “Totality”. |
|
Error when you use |
|
Warn about unused local variables. |
|
Warn about unused function parameters. Prefix your parameter name with |
|
Enforce type safety for |
|
Enforce that functions are contravariant in their parameter and |
|
Promote |
|