|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 | 8 |
|
| 9 | +import {R3Identifiers} from '@angular/compiler'; |
9 | 10 | import ts from 'typescript';
|
10 | 11 |
|
11 | 12 | import {ComponentDecoratorHandler, DirectiveDecoratorHandler, InjectableDecoratorHandler, NgModuleDecoratorHandler, NoopReferencesRegistry, PipeDecoratorHandler, ReferencesRegistry} from '../../annotations';
|
@@ -39,6 +40,7 @@ import {getSourceFileOrNull, isDtsPath, toUnredirectedSourceFile} from '../../ut
|
39 | 40 | import {Xi18nContext} from '../../xi18n';
|
40 | 41 | import {DiagnosticCategoryLabel, NgCompilerAdapter, NgCompilerOptions} from '../api';
|
41 | 42 |
|
| 43 | +import {coreHasSymbol} from './core_version'; |
42 | 44 | import {coreVersionSupportsFeature} from './feature_detection';
|
43 | 45 |
|
44 | 46 | const SHOULD_USE_TEMPLATE_PIPELINE = true;
|
@@ -798,10 +800,15 @@ export class NgCompiler {
|
798 | 800 |
|
799 | 801 | const useInlineTypeConstructors = this.programDriver.supportsInlineOperations;
|
800 | 802 |
|
801 |
| - // Only Angular versions greater than 17.2 have the necessary symbols to type check signals in |
802 |
| - // two-way bindings. We also allow version 0.0.0 in case somebody is using Angular at head. |
803 |
| - const allowSignalsInTwoWayBindings = this.angularCoreVersion === null || |
804 |
| - coreVersionSupportsFeature(this.angularCoreVersion, '>= 17.2.0-0'); |
| 803 | + // Check whether the loaded version of `@angular/core` in the `ts.Program` supports unwrapping |
| 804 | + // writable signals for type-checking. If this check fails to find a suitable .d.ts file, fall |
| 805 | + // back to version detection. Only Angular versions greater than 17.2 have the necessary symbols |
| 806 | + // to type check signals in two-way bindings. We also allow version 0.0.0 in case somebody is |
| 807 | + // using Angular at head. |
| 808 | + let allowSignalsInTwoWayBindings = |
| 809 | + coreHasSymbol(this.inputProgram, R3Identifiers.unwrapWritableSignal) ?? |
| 810 | + (this.angularCoreVersion === null || |
| 811 | + coreVersionSupportsFeature(this.angularCoreVersion, '>= 17.2.0-0')); |
805 | 812 |
|
806 | 813 | // First select a type-checking configuration, based on whether full template type-checking is
|
807 | 814 | // requested.
|
|
0 commit comments