TypeScript 6.0 Features in Angular 22
Exploring the key changes in TypeScript's bridge release to the native Go-based TS 7.0
1. strict: true by Default
TypeScript 6.0 enables strict mode by default in new projects. Previously, you had to explicitly opt in to strict checking with "strict": true in your tsconfig. Now all strict family flags , strictNullChecks, strictFunctionTypes, strictBindCallApply, noImplicitAny, and more , are on unless you explicitly disable them.
strict: true, so this change mainly aligns the broader TypeScript ecosystem with Angular's existing best practice. // tsconfig.json in TS 5.x (opt-in)
{
"compilerOptions": {
"strict": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"noImplicitAny": true
}
}
// tsconfig.json in TS 6.0 (all on by default!)
{
"compilerOptions": {
// "strict": true is now the DEFAULT
// No need to set it explicitly
}
}2. Temporal API Types
TypeScript 6.0 ships built-in type definitions for the Temporal API, the modern replacement for Date. Temporal provides immutable, timezone-aware date/time objects with a clear, unambiguous API.
// Temporal API , native date/time handling
const now = Temporal.Now.instant();
console.log(now.toString());
const date = Temporal.PlainDate.from('2026-01-15');
const today = Temporal.Now.plainDateISO();
const diff = today.until(date);
console.log(diff.days); // days between3. Map.getOrInsert() / getOrInsertComputed()
New Map methods that atomically get an existing value or insert a default. getOrInsert(key, default) uses a static default value, while getOrInsertComputed(key, fn) lazily computes it. This eliminates the common "check-then-set" pattern.
getOrInsertComputed() — Lazy Cache Demo
getOrInsertComputed(key, fn) only calls the callback when the key is missing. Try adding the same word twice — the second lookup hits the cache without recomputing.
// Map.getOrInsert() , default value if key missing
const freq = new Map<string, number>();
for (const word of words) {
// getOrInsert returns existing value or inserts default
const count = freq.getOrInsert(word, 0);
freq.set(word, count + 1);
}
// getOrInsertComputed , lazy default via callback
const cache = new Map<string, ExpensiveResult>();
const result = cache.getOrInsertComputed(key, (k) => {
return computeExpensiveResult(k);
});4. RegExp.escape()
Safely escapes special regular expression characters in a string. Essential when building regex patterns from user input , no more hand-rolled escape functions.
RegExp.escape() is not available in this runtime yet. TypeScript 6.0 provides the type definitions for this TC39 Stage 4 proposal. // RegExp.escape() , safely escape special chars
const userInput = 'price is $9.99 (USD)';
const escaped = RegExp.escape(userInput);
// Result: "price\ is\ \$9\.99\ \(USD\)"
const regex = new RegExp(escaped, 'g');
const text = 'The price is $9.99 (USD). Done.';
const matches = text.match(regex);5. New Defaults Summary
TypeScript 6.0 is the bridge release preparing the ecosystem for TypeScript 7.0, which will be rewritten in Go for dramatically faster compilation. TS 6.0 modernizes the default compiler options so new projects start with sensible, modern settings.
| Setting | Old Default (TS 5.x) | New Default (TS 6.0) |
|---|---|---|
strict | false | true |
module | "commonjs" | "nodenext" |
target | "es3" | "esnext" |
types | (all @types) | (explicit only) |
rootDir | (inferred) | "./src" |
esModuleInterop | false | true |
tsconfig.json are unaffected.