diff --git a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts b/packages/compiler-cli/src/ngtsc/core/src/compiler.ts index f2b4a8e7b4..83e2e61e81 100644 --- a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts +++ b/packages/compiler-cli/src/ngtsc/core/src/compiler.ts @@ -33,6 +33,8 @@ import {OptimizeFor, TemplateTypeChecker, TypeCheckingConfig, TypeCheckingProgra import {getSourceFileOrNull, isDtsPath, resolveModuleName} from '../../util/src/typescript'; import {LazyRoute, NgCompilerAdapter, NgCompilerOptions} from '../api'; +import {compileUndecoratedClassesWithAngularFeatures} from './config'; + /** * State information about a compilation which is only generated once some data is requested from * the `NgCompiler` (for example, by calling `getDiagnostics`). @@ -1012,10 +1014,7 @@ export class NgCompiler { new DirectiveDecoratorHandler( reflector, evaluator, metaRegistry, scopeRegistry, metaReader, defaultImportTracker, injectableRegistry, isCore, this.closureCompilerEnabled, - // In ngtsc we no longer want to compile undecorated classes with Angular features. - // Migrations for these patterns ran as part of `ng update` and we want to ensure - // that projects do not regress. See https://hackmd.io/@alx/ryfYYuvzH for more details. - /* compileUndecoratedClassesWithAngularFeatures */ false + compileUndecoratedClassesWithAngularFeatures, ) as Readonly>, // clang-format on // Pipe handler must be before injectable handler in list so pipe factories are printed diff --git a/packages/compiler-cli/src/ngtsc/core/src/config.ts b/packages/compiler-cli/src/ngtsc/core/src/config.ts new file mode 100644 index 0000000000..e59c7c80ac --- /dev/null +++ b/packages/compiler-cli/src/ngtsc/core/src/config.ts @@ -0,0 +1,16 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +// This file exists as a target for g3 patches which change the Angular compiler's behavior. +// Separating the patched code in a separate file eliminates the possibility of conflicts with the +// patch diffs when making changes to the rest of the compiler codebase. + +// In ngtsc we no longer want to compile undecorated classes with Angular features. +// Migrations for these patterns ran as part of `ng update` and we want to ensure +// that projects do not regress. See https://hackmd.io/@alx/ryfYYuvzH for more details. +export const compileUndecoratedClassesWithAngularFeatures = false;