Anatomy of a tsc error
Every tsc error has the same four parts, in the same order, whether it is one line or fifty. Learning to parse the shape — not the specific message — is what makes an error in a library you have never opened readable on sight.
app.ts:3:1 - error TS2322: Type 'string' is not assignable to type 'number'.
3 age = "thirty"
~~~- 1file:line:col
app.ts:3:1— the file, then the exact line and column the checker was looking at when it decided something was wrong. Your editor jumps straight here. - 2The TS code
TS2322— a stable, searchable number. The same bug always produces the same code, so this is what you paste into a search engine, not the whole sentence. - 3The message
"Type 'string' is not assignable to type 'number'." — plain English, but read literally: it names the two types in conflict, in the order source-type then target-type.
- 4Source context
The numbered line, and a row of
~~~under exactly the span the checker means. On a long line this is what tells you which sub-expression is the problem, not the whole statement.
| Signal | What it tells you |
|---|---|
Position of the ~~~ | The narrowest expression the checker blames — often not the whole line |
| Order of types in the message | Almost always "the thing you have" then "the thing it needed to be" |
| Multiple stacked errors on one run | Read the first one first — later ones are frequently just consequences of it |
| A message several paragraphs long | A nested/generic mismatch — read it bottom-up (last lesson in this module) |
tsc's default, colourised, human-friendly format. Plain CI logs sometimes show the same information without the squiggle, as a single line — the file:line:col and TS code are always there either way; that is the part to anchor on.