TypeScript for Enterprise Applications - Part 2
Advanced Configuration for TypeScript for applications at the scale of Enterprise.
tsconfig.json
is a configuration file for TypeScript projects. It is located in the root folder of a TypeScript project and contains compiler options to compile the TypeScript code..
tsc cli-tool
, if invoked without parameters, starts searching for tsconfig.json
in the current directory and moves up the parent directories until it finds the file. Alternatively, you can specify the file's location using the --project
parameter.With the option "strict": true
, it ensures strong correctness of a program by enabling these checks:noImplicitAny
restricts to define explicit any
for a variable.
noImplicitThis
raises error when there is athis
is any implicitany
.alwaysStrict
JS "use strict" mode.strictBindCallApply
restricts bind, call and apply calling underlying function with correct type.strictNullChecks
restricts using null explicit.strictFunctionTypes
function parameters to be checked for their types.strictPropertyInitialization
give value to properties.noUnusedLocals stops you using unused local variables.
noUnusedparameters restricts you using unused parameter with prefix "_"
noImplicitReturns
restricts return typenoFallthroughCasesInSwitch
returns error if non-empty case doesn't do break or return.types
specify @types/* packages to be included.stripInternal
information meant only for internal purposes.exactOptionalPropertyTypes
It stops usingundefined
as an optional property.noUncheckedIndexedAccess
undeclared keys should be assigned toundefined
so they won't go unchecked.noPropertyAccessFromIndexSignature
property should be accessed using the"[]"
syntax and not the"."
syntax.noImplicitOverride
should specify 'override' explicitly.allowSyntheticDefaultImports
allow commonJS module as ESM module.esModuleInterop
manages interoperability of ESM and CJS.skipDefaultLibCheck
stops breaking changes from node_modules.useUnknownInCatchVariables
errors caught will be promoted tounknown
instead ofany
.