From f59ac695cfe1f089a267fc7a0fa455dc9be82c86 Mon Sep 17 00:00:00 2001 From: Matthieu Riegler Date: Mon, 1 Dec 2025 13:49:51 +0100 Subject: [PATCH] fix(@schematics/angular): remove `experimentalDecorators` from new projects `experimentalDecorators: true` was required to use constructor DI. With recommendation now to use `inject` for DI, new projects don't need the experimental decorators anymore. --- .../schematics/angular/workspace/files/tsconfig.json.template | 1 - .../build/library/lib-unused-decorated-class-treeshake.ts | 2 +- tests/legacy-cli/e2e/tests/i18n/setup.ts | 4 ++-- tests/legacy-cli/e2e/tests/vitest/tslib-resolution.ts | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/schematics/angular/workspace/files/tsconfig.json.template b/packages/schematics/angular/workspace/files/tsconfig.json.template index d51e03ac01fe..9c8ab7dd5925 100644 --- a/packages/schematics/angular/workspace/files/tsconfig.json.template +++ b/packages/schematics/angular/workspace/files/tsconfig.json.template @@ -10,7 +10,6 @@ "noFallthroughCasesInSwitch": true,<% } %> "skipLibCheck": true, "isolatedModules": true, - "experimentalDecorators": true, "importHelpers": true, "target": "ES2022", "module": "preserve" diff --git a/tests/legacy-cli/e2e/tests/build/library/lib-unused-decorated-class-treeshake.ts b/tests/legacy-cli/e2e/tests/build/library/lib-unused-decorated-class-treeshake.ts index 33b221a32efe..91a4c41a4d65 100644 --- a/tests/legacy-cli/e2e/tests/build/library/lib-unused-decorated-class-treeshake.ts +++ b/tests/legacy-cli/e2e/tests/build/library/lib-unused-decorated-class-treeshake.ts @@ -14,7 +14,7 @@ export default async function () { 'projects/my-lib/src/lib/my-lib.ts', ` function something() { - return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) { + return function (originalMethod: any, context: ClassMethodDecoratorContext) { console.log("someDecorator"); }; } diff --git a/tests/legacy-cli/e2e/tests/i18n/setup.ts b/tests/legacy-cli/e2e/tests/i18n/setup.ts index 99d71f9bbe4b..1a3ee401590d 100644 --- a/tests/legacy-cli/e2e/tests/i18n/setup.ts +++ b/tests/legacy-cli/e2e/tests/i18n/setup.ts @@ -100,7 +100,7 @@ export async function setupI18nConfig() { await writeFile( 'src/app/app.ts', ` - import { Component, Inject, LOCALE_ID } from '@angular/core'; + import { Component, inject, LOCALE_ID } from '@angular/core'; import { DatePipe } from '@angular/common'; import { RouterOutlet } from '@angular/router'; @@ -110,7 +110,7 @@ export async function setupI18nConfig() { templateUrl: './app.html' }) export class App { - constructor(@Inject(LOCALE_ID) public locale: string) { } + locale = inject(LOCALE_ID); title = 'i18n'; jan = new Date(2000, 0, 1); minutes = 3; diff --git a/tests/legacy-cli/e2e/tests/vitest/tslib-resolution.ts b/tests/legacy-cli/e2e/tests/vitest/tslib-resolution.ts index 759d5e2b5728..71903687fb0f 100644 --- a/tests/legacy-cli/e2e/tests/vitest/tslib-resolution.ts +++ b/tests/legacy-cli/e2e/tests/vitest/tslib-resolution.ts @@ -14,7 +14,7 @@ export default async function () { 'src/app/custom-decorator.ts', ` export function MyDecorator() { - return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) { + return function (originalMethod: any, context: ClassMethodDecoratorContext) { // do nothing }; }