New Features in TypeScript 5.0: Decorators, Const Type Parameters, Module Resolution, JSDoc Enhancements and Performance Improvements
TypeScript 5.0 introduces a host of enhancements—including a new decorator standard, const type parameters, expanded JSDoc support, multiple tsconfig extends, improved module resolution options, verbatim module syntax, and performance optimizations—along with detailed examples and guidance for developers.
On March 17, 2023 TypeScript 5.0 was officially released, bringing a series of language and tooling improvements aimed at making TypeScript smaller, simpler, and faster.
Major language updates
New decorator standard : decorators can now be written as functions that wrap methods, enabling logging, binding, and other cross‑cutting concerns. function loggedMethod(originalMethod: any, _context: any) { return function replacementMethod(this: any, ...args: any[]) { console.log("LOG: Entering method."); const result = originalMethod.call(this, ...args); console.log("LOG: Exiting method."); return result; }; }
Const type parameters : the const modifier can be used on generic type parameters to preserve literal types without needing as const . type HasNames = { names: readonly string[] }; function getNamesExactly<const T extends HasNames>(arg: T): T["names"] { return arg.names; } const names = getNamesExactly({ names: ["Alice", "Bob", "Eve"] });
Multiple extends in tsconfig.json : a configuration file can now inherit from an array of base configs, merging their compiler options. { "extends": ["@tsconfig/strictest/tsconfig.json", "../../../tsconfig.base.json"], "compilerOptions": { "outDir": "../lib" } }
Enhanced module resolution : new "moduleResolution": "bundler" option mirrors the behavior of modern bundlers, while node16 and nodenext continue to support strict ESM rules. { "compilerOptions": { "target": "esnext", "moduleResolution": "bundler" } }
Custom parsing flags : flags such as --allowImportingTsExtensions , --resolvePackageJsonExports , and --allowArbitraryExtensions give finer control over how TypeScript resolves imports and package exports.
Verbatim module syntax : the --verbatimModuleSyntax flag preserves all non‑type imports/exports in the emitted JavaScript, simplifying inter‑op with CommonJS and ESM.
JSDoc enhancements : new @satisfies and @overload tags allow JavaScript files to benefit from the same type‑checking capabilities as TypeScript. /** @satisfies {ConfigSettings} */ let myConfig = { compilerOptions: { strict: true, outDir: "../lib" }, extends: ["@tsconfig/strictest/tsconfig.json"] };
Other improvements
TypeScript 5.0 also adds case‑insensitive import sorting in editors, a more robust switch/case completion experience, and substantial speed, memory, and package‑size optimizations that reduce the overall npm package size by over 26 MB.
These changes make TypeScript a more powerful and performant tool for both frontend and backend development.
IT Services Circle
Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.