TypeScript checks and then deletes. The compiler reads the annotations,
reports what does not fit, and emits JavaScript with every type stripped out, so
nothing on this page exists at runtime. A value arriving from a network call is
whatever the server sent, whatever the interface said, and the only place that
was ever checked is the editor.
Which makes the compiler settings the whole subject, because they decide how
much is checked before that deletion happens. Four of them carry most of the
value.
strictNullChecks: without it,nullandundefinedare members of every type, so aDockthat might be missing type-checks as aDocknoImplicitAny: a parameter with no annotation stops being a
silentanyand becomes an error you have to answerstrictFunctionTypes: a callback taking a wider type can no
longer be passed where a narrower one is expectednoUncheckedIndexedAccess:docks[3]becomesDock | undefined, which is the truth about an array index and the
setting most teams never turn on
The escape hatch, and the honest one
any switches checking off for that value and everything it
touches, silently and permanently. It is not a weaker type, it is the absence of
one, and a single any at an API boundary propagates through every
function it is passed to.
Boundary types
Why any switches checking off while unknown forces proof
Both describe a value whose shape is not yet known, but only one stops unsafe calls before you narrow it.
- any (escape hatch)Absence of a type, not a weaker one
- Disables checks on that value permanently
- Propagates through every function it touches
- Leaves editor types downstream as decoration
- unknown (honest type)Refuses every operation until narrowed
- Requires a guard like typeof x === "string"
- Unlocks operations only inside the checked branch
- Keeps types inward of the boundary meaningful
Untyped value entering a function
Reaching for unknown at every boundary and narrowing inward is what separates checked codebases from silent assertions.
Interactive Practice Lab
Edit and run this snippet directly in your browser (zero setup)
const scores = [78, 92, 64, 95, 88];const passed = scores.filter((n) => n >= 70);const avg = passed.reduce((a, b) => a + b, 0) / passed.length;console.log('Passed count:', passed.length);console.log('Average score:', avg.toFixed(1));Live Big-O Complexity & Binary Search Race Lab
Compare complexity curves at scale and watch Linear vs Binary Search race live.
unknown is the honest version. It also means the shape is not
known, and it refuses every operation until the code proves what it is, soif (typeof x === "string") narrows it and only inside that branch
can it be used as a string. Reaching for unknown at every boundary
and narrowing inward is the single habit that separates a codebase where the
types mean something from one where they are decoration.
What the types cannot do
A response parsed with JSON.parse is typed any, and
annotating it as Dock asserts rather than checks: the compiler
believes you and emits nothing. So the field that the API renamed last week is
still missing, the code still reads dock.code, and the failure is
at runtime with a type system that reported no problem.
Compile vs runtime
What stops bad API shapes before dock.code runs
Type assertions vanish when TypeScript emits JavaScript, so only a runtime parser catches a renamed field.
- Assertion with as Dock+Compiler errors in the editor only→Renamed or missing fields straight to runtime
- Schema validator at the boundary+Mismatched JSON payloads by throwing on parse→Validated values carrying the derived type
- Typed functions inside the boundary+Internal callers drifting from the schema→Consistent data matching one shared definition
Deriving the static type from the boundary schema guarantees the runtime check and the TypeScript type cannot drift apart.
The fix is a real check at that one boundary. A schema validator parses the
response and either returns a typed value or throws, and the type is derived
from the schema so the two cannot drift. Everything inside the boundary is then
genuinely checked, which is what people believe TypeScript is doing already.
What to run in 2026
TypeScript's own compiler is the tool, free and open source, and the setting
to reach for on a new project is "strict": true in tsconfig, which
turns on the first three above in one line. It replaced enabling flags
individually and discovering years later that one was off. Turning it on for an
existing codebase is the hard case, and the workable route is one directory at a
time rather than one flag at a time.
What to run in 2026
Enabling strict checking and schema parsing without stalling
Start new projects with one flag, migrate older directories one by one, and infer boundary types with Zod.
- new codeTurn on "strict": true in tsconfigEnables strictNullChecks, noImplicitAny, and strictFunctionTypes in one line01
- 02legacy codeMigrate existing code one directory at a timeMore workable than flipping one global flag across every file at once
- 2026 defaultValidate incoming data with a Zod schemaReplaces hand-written type guards that go stale when APIs change03
- 04single sourceInfer the TypeScript type from the schemaKeeps the runtime parser and static type locked together
TypeScript and Zod are both free and open source; inferring types from schemas prevents silent drift when endpoints change.
Zod is the schema validator most commonly reached for in 2026, free and open
source. A schema is written once and the TypeScript type is inferred from it, so
the parse and the type cannot disagree. It replaced hand written type guards,
which are correct on the day they are written and are not updated when the API
changes, which is exactly when they were needed.
Where this stalls people
The stall is believing the errors are gone because the editor is quiet. A
codebase with strict off, any at every boundary andas assertions over parsed responses reports nothing and checks
almost nothing, and it takes longer to write than plain JavaScript for no return
at all. The annotations are then blamed for the cost.
One tsconfig, five positions
How much is actually checked before the types are deleted
Every position here compiles and ships identical JavaScript, and only the reader of the editor can tell them apart.
Checking strength from unchecked assertions to boundary schemas
- any at every boundaryChecking is off wherever data enters, and inward of that too
- strict offnull belongs to every type, so a missing Dock is a Dock
- strict: trueThe three flags most of the value lives in, in one line
- plus noUncheckedIndexedAccessdocks[3] is Dock or undefined, which is the truth
- schema at every boundaryunknown inward, parsed once, and the type derived from the schema
The placements are this page's reading of what each setting buys, not a standard. What no position on this rail changes is the emitted JavaScript, which is why the rightmost one still needs a validator that runs.
The measurement that tells you which codebase you are in: search forany and for as, and count. If either is common at the
edges, the type system is switched off there and everything inward of it is
resting on an assertion. What the types are protecting you from underneath is
types, functions
and the parts that surprise people, where the untyped values arrive from is
programs talking to programs, and the
compile step itself is
translated
ahead of time, or read as it goes, all inside
the only language a browser
runs.