TypeScript 5.x Features Worth Using Today (With Real Examples)
TypeScript 5.0 landed in March 2023, and the releases since have added a steady run of small, practical features. The TypeScript 5 features worth using are the ones that remove boilerplate, catch bugs earlier, or make intent clearer, and this guide covers seven of them with code you can paste into a real project. If your codebase is still plain JavaScript, start with this step-by-step guide to migrating a JavaScript project to TypeScript before adopting the features below.
A note on versions: each feature below names the minor release it arrived in. Most teams run the latest 5.x, so all of them should be available to you. If you are pinned to an older version, the version notes tell you exactly what you are missing.
const Type Parameters (TypeScript 5.0)
Before 5.0, generic functions widened literal types by default. Pass ["a", "b"] into a generic helper and TypeScript inferred string[], losing the exact values. The usual fix was as const at the call site, which pushed the work onto every caller.
Const type parameters move that fix into the function definition. Add const before the type parameter and TypeScript infers the narrowest literal type instead:
function asTuple<const T extends readonly unknown[]>(...args: T): T {
return args;
}
const pair = asTuple("id", 42);
// pair: readonly ["id", 42]
const withoutConst = (x: string | number) => x;
// T would infer as (string | number)[] without const
This matters most in helpers that build config objects, route tables, or event maps, where the exact string literals are the whole point. One keyword in the definition replaces as const at dozens of call sites.
The satisfies Operator Keeps Types Honest
The satisfies operator landed in 4.9 and is standard in every 5.x release, so it belongs on this list. It checks that a value matches a type without widening the value the way a type annotation does, and without hiding mistakes the way a type assertion does.
type Theme = {
primary: string;
radius: number;
};
const theme = {
primary: "#2563eb",
radius: 8,
accent: "#f59e0b",
} satisfies Theme;
// theme.accent is still accessible: "#f59e0b"
// a typo in "primary" is a compile error
Compare the alternatives. Annotating with : Theme widens primary to string and drops accent from the type entirely. Asserting with as Theme skips excess property checks, so a typo slips through. Satisfies gives you the check and keeps the precise type. Use it for config objects, theme definitions, and any literal object that must conform to a shape.
Standardized Decorators Are Finally Safe to Use (TypeScript 5.0)
TypeScript 5.0 adopted the TC39 standard decorator syntax. The old experimentalDecorators flag still works, but new code should use the standard form, which is what the JavaScript language itself is converging on. That means TypeScript decorators you write today will not need a rewrite when the standard finalizes.
function log(
method: (...args: any[]) => unknown,
context: ClassMethodDecoratorContext,
) {
const name = String(context.name);
return function (this: unknown, ...args: any[]) {
console.log(`Calling ${name}`);
return method.apply(this, args);
};
}
class ApiClient {
@log
fetchUsers() {
return ["ana", "ben"];
}
}
Decorators fit the same cross-cutting jobs as the classic patterns in our guide to design patterns every developer should know: logging, timing, caching, and access checks that would otherwise repeat in every method. One rule: do not mix the old experimental syntax and the new standard syntax in the same project. Pick the standard form and migrate old decorators when you touch them.
NoInfer Stops TypeScript Guessing Wrong (TypeScript 5.4)
Sometimes TypeScript infers a type parameter from two places at once and picks the wrong one. A common case is a function that takes a fallback value and a candidate value: you want the fallback to set the type and the candidate to be checked against it, not to widen the type.
function pick<T>(fallback: T, value: NoInfer<T>): T {
return value ?? fallback;
}
const port = pick(3000, 8080); // number, fine
const bad = pick(3000, "oops"); // error: string is not assignable to number
Without NoInfer, the second argument would widen T to number | string and the mistake would compile. NoInfer tells the compiler to infer T from the first argument only and check the second against it. Reach for it whenever a generic function has one argument that should define the type and another that should only be validated.
Inferred Type Predicates Cut Boilerplate (TypeScript 5.5)
Filtering out null and undefined used to need a hand-written type guard, or the result stayed (string | null)[] and every later line fought the type. TypeScript 5.5 infers the predicate for you:
const values = ["a", null, "b", undefined, "c"];
const strings = values.filter((v) => v !== null && v !== undefined);
// strings: string[] — no explicit guard needed
const numbers = [1, null, 2].filter((n) => n !== null);
// numbers: number[]
This is a small change with a large payoff, because filtering nullable values is one of the most common operations in real code. It also removes the most copy-pasted type guard in many codebases: (v): v is string => v !== null. Keep the explicit guard when the check is complex, but for simple null checks, let the compiler do it.
using Declarations Clean Up After Themselves (TypeScript 5.2)
The using declaration, from the explicit resource management proposal, ties cleanup to scope. When a variable declared with using goes out of scope, TypeScript calls its [Symbol.dispose] method automatically:
class FileHandle implements Disposable {
constructor(private name: string) {}
read() {
return `contents of ${this.name}`;
}
[Symbol.dispose]() {
console.log(`Closing ${this.name}`);
}
}
function processFile() {
using file = new FileHandle("data.txt");
return file.read();
// file is closed here, even if read() throws
}
Use it for file handles, database connections, and temporary locks, anywhere a forgotten cleanup becomes a leak. Two caveats: your target library needs esnext.disposable types, and runtime support for Symbol.dispose varies, so check your Node version or add a polyfill before relying on it in production. A leaked handle shows up as a runtime bug rather than a type error, and that is where this deep dive into debugging JavaScript in Chrome DevTools earns its keep.
TypeScript 5 Features Worth Using in a Real Codebase
If you adopt nothing else, start with const type parameters and the satisfies operator. Both are low risk, need no config change, and pay off in the first file you touch. Add standard decorators if your code uses classes, NoInfer where inference fights you, inferred type predicates when cleaning up filters, and using declarations where resources leak.
TypeScript 5.6 added one more quiet safety net: the compiler now flags truthiness checks on values that are always truthy, which catches conditions that can never be false. Combined with the features above, the 5.x line is less about new syntax and more about the compiler catching mistakes that used to reach production.
If you are still weighing whether the move from JavaScript is worth it, this TypeScript vs JavaScript comparison for 2026 lays out the trade-offs. And if your test suite still leans on loose types, these features pay off fastest in tests, so compare Jest, Vitest, and Mocha and pick the runner that fits your setup.
Frequently Asked Questions
Do I need to upgrade to TypeScript 5 to use these features?
Most of them, yes. Each section names its release, from 5.0 for const type parameters and decorators to 5.5 for inferred type predicates. The satisfies operator is the exception: it arrived in 4.9, so it works on any 5.x version.
Will these features break my existing code?
Almost all of them are additive and safe to adopt file by file. The one to plan is decorators: moving from the experimental syntax to the standard syntax changes how decorators are written, so migrate them deliberately rather than in a bulk find-and-replace. Run tsc --noEmit after any upgrade to catch surprises.
Which feature should I adopt first?
Const type parameters and the satisfies operator. Both work without config changes, both make existing code safer the moment you use them, and neither changes runtime behaviour.