ARTICLE AD BOX
I generated an Angular app via Angular CI with latest v21. When I add
const formatter = new Intl.DurationFormat('en', { style: 'narrow' });
in TypeScript code and "npm run start" the application, it shows the error:
Application bundle generation failed. [0.914 seconds] - 2026-05-21T06:04:49.787Z X [ERROR] TS2339: Property 'DurationFormat' does not exist on type 'typeof Intl'. [plugin angular-compiler] src/app/app.ts:14:31: 14 │ ...nst formatter = new Intl.DurationFormat('de', { style: 'narrow'...In my understanding, Angular should already use a browserslist configuration that supports Intl.DurationFormat as it is baseline March 2025 available according to MDN.
What do I need to do to use this Intl feature without transpilation errors? Setting tsconfig.json's "target": "esnext" did not work, same error.
Angular v21 pins Typescript to versions >=5.9.0 <6.0.0, but Intl.DurationFormat was introduced in Typescript at version 6.0.0, so this is currently not possible without a workaround.
You can simply copy the type definitions from es2025.intl.d.ts into your project and it will work. Once angular supports Typescript >=6.0.0 you just remove it.
If you want to support older browsers you'll need a polyfill anyway and could just use @formatjs/intl-durationformat.
Demo
Explore related questions
See similar questions with these tags.
