🧪Static Analysis
Also known as Static Code Analysis, Static Checking, SAST
Checking code for mistakes just by reading it. It is never run.
Think of it like
Think of it like a spell checker. It reads your writing and marks mistakes before anyone sees them.
Example
Jack saves a file, and the type checker flags line 2 at once. He has put the text ten into a variable meant for numbers.
Why it matters
It is the cheapest check there is. It runs on every save and finds whole kinds of bug for free.
Definition
Example code
console
$ npx tsc --noEmit price.ts
price.ts(2,1): error TS2322: Type 'string' is not assignable to type 'number'.Common mistake
Key takeaways
- 1Reads, never runs. Checks the source.
- 2Linters and type checkers. The common kinds.
- 3Before any test. Seconds, on every save.