TSC
↔ CLI Dev tool to Type-Check/Compile TS to JS
aka TSC, TypeScript-Standalone-Compiler, TypeScript-Compiler, TS-Standalone-Compiler, TS-Compiler
uses static code analysis to reduce Runtime Error
TS Compiler will throw errors or provide warnings before executing code - helps catch easy mistakes like typos
high-level compiler that takes a TS file and outputs and JS file
Type annotations erased from JS file due to lack of TypeScript compatibility with browsers & runtimes
Type Assertion
TS Syntax to override TSC's Type Inference for Static Type of specific Value
Type Inference
(feature) TSC to auto-derive implicit Type for Variable (w/o explicit Type Annotation)
default tsc transpiles .ts to .js - even if type errors occur
prevent TS compiler updating index.ts to js file if type error found
tsc --noEmitOnError index.ts
TSC Directive
comment statement as Directive to control TSC behavior on line/file basis
References
--noImplicitAny
↔ to flag TSC to prevent Type Inference forany
- enforce explicit Type for Parameter, Exception, etcLanguage Service
↔ component layer of TSC to provide tool integration with IDE for more featurestsc --strict
↔ to flag TSC auto-set max strictness settings, apply true to:--noImplicitAny
,--noImplicitThis
,--alwaysStrict
,--strictNullChecks
,--strictFunctionTypes
,--strictPropertyInitialization
--noImplicitThis
↔ to flag TSC to throw error when Type ofthis
keyword unclear--strictNullChecks
↔ to flag TSC to throw error when null is not explicitly defined--strictFunctionTypes
↔ to flag TSC to enforce stronger checks for function Types--strictPropertyInitialization
↔ flag to set TSC to throw error when properties inclass
definitions are not initializedType Inference
↔ (feature) TSC to auto-derive implicit Type for Variable (w/o explicit Type Annotation)tsconfig.json
↔ TS Manifest to config TSC behaviorrun [**_
TSC_**](tsc_ts-def) in root folder which has typescript config file
↔tsc
npx tsc
// @ts-
nocheck` ↔ tell TSC to not Type-Check this file// @ts-
check` ↔ tell TSC to check this (JS?) file// @ts-
expect-error` ↔ tell TSC to expect & suppress static error on next lineWatch Mode
↔ TSC mode to continuously monitor & recompile upon Code change (save)run [**_
TSC_**](tsc_ts-def) in [
Watch Mode](watch-mode) for app.ts
↔tsc app.ts -w
"exclude": ["_FILE_PATHS", "_OR_ENTIRE_FOLDERS_"]
↔ to exclude file/dir from TSC"files": ["_FILEONLY_"]
↔ to include file for TSC"lib": []
↔ to set which default objects & features TSC knowsType Assertion
↔ TS Syntax to override TSC's Type Inference for Static Type of specific ValueGeneric Type
↔ factory for Types, defined using Angle Bracket Notation, to annotate with Generic Type Placeholder for TSC to infer & fill infunction type inference
↔ TSC only infers Type of return values, ignores Type of param args// @ts-ignore
↔ tell TSC to ignore Type-Check for next line onlyTSC Directive
↔ comment statement as Directive to control TSC behavior on line/file basis--alwaysStrict
↔ to flag TSC to apply Strict Modetsc --init
↔ init TSC in project w/o TS