Skip to content

Commit 60fd6ae

Browse files
committed
2c17145 refactor(compiler): element references not resolved when selectorless matcher is passed in (#61100)
1 parent f48bdf9 commit 60fd6ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+698
-322
lines changed

BUILD_INFO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Mon May 5 16:31:10 UTC 2025
2-
310e5ffe24349963c1e7a6b1d5171e6caf5d8399
1+
Mon May 5 21:44:29 UTC 2025
2+
2c1714552065acee5c50cd37bfc6f29a6701b8ea

api.d-CRxC7NlU.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

chrome_dev_tools_performance.d-B0FzTuRf.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

discovery.d-CBxzK1ay.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

event_dispatcher.d-DlbccpYq.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

fesm2022/attribute-BWp59EjE.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

fesm2022/core.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/
@@ -622,7 +622,7 @@ class Version {
622622
/**
623623
* @publicApi
624624
*/
625-
const VERSION = new Version('20.1.0-next.0+sha-310e5ff');
625+
const VERSION = new Version('20.1.0-next.0+sha-2c17145');
626626

627627
function compileNgModuleFactory(injector, options, moduleType) {
628628
ngDevMode && assertNgModuleType(moduleType);

fesm2022/core.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fesm2022/debug_node-3mmnD06K.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/
@@ -14551,7 +14551,7 @@ class ComponentFactory extends ComponentFactory$1 {
1455114551
}
1455214552
function createRootTView(rootSelectorOrNode, componentDef, componentBindings, directives) {
1455314553
const tAttributes = rootSelectorOrNode
14554-
? ['ng-version', '20.1.0-next.0+sha-310e5ff']
14554+
? ['ng-version', '20.1.0-next.0+sha-2c17145']
1455514555
: // Extract attributes and classes from the first selector only to match VE behavior.
1455614556
extractAttrsAndClassesFromSelector(componentDef.selectors[0]);
1455714557
let creationBindings = null;

fesm2022/debug_node-3mmnD06K.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fesm2022/primitives/di.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

fesm2022/primitives/event-dispatch.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

fesm2022/primitives/signals.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

fesm2022/resource-nrAenwIA.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

fesm2022/root_effect_scheduler-B_EWGyLU.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

fesm2022/rxjs-interop.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

fesm2022/signal-ePSl6jXn.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

fesm2022/testing.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

fesm2022/untracked-2ouAFbCz.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

fesm2022/weak_ref-BaIq-pgY.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

graph.d-BcIOep_B.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/core",
3-
"version": "20.1.0-next.0+sha-310e5ff",
3+
"version": "20.1.0-next.0+sha-2c17145",
44
"description": "Angular - the core framework",
55
"author": "angular",
66
"license": "MIT",
@@ -46,7 +46,7 @@
4646
"tslib": "^2.3.0"
4747
},
4848
"peerDependencies": {
49-
"@angular/compiler": "20.1.0-next.0+sha-310e5ff",
49+
"@angular/compiler": "20.1.0-next.0+sha-2c17145",
5050
"rxjs": "^6.5.3 || ^7.4.0",
5151
"zone.js": "~0.15.0"
5252
},

primitives/di/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

primitives/event-dispatch/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

primitives/signals/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

rxjs-interop/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license Angular v20.1.0-next.0+sha-310e5ff
2+
* @license Angular v20.1.0-next.0+sha-2c17145
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/

schematics/bundles/apply_import_manager-Coc7Hewu.js renamed to schematics/bundles/apply_import_manager-D1v4pj2G.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use strict';
22
/**
3-
* @license Angular v20.1.0-next.0+sha-310e5ff
3+
* @license Angular v20.1.0-next.0+sha-2c17145
44
* (c) 2010-2025 Google LLC. https://angular.io/
55
* License: MIT
66
*/
77
'use strict';
88

99
var ts = require('typescript');
1010
require('os');
11-
var checker = require('./checker-BAl7CJ0l.js');
12-
var project_paths = require('./project_paths-Bl-H7Vlb.js');
11+
var checker = require('./checker-CrYP6hli.js');
12+
var project_paths = require('./project_paths-lNg6crpG.js');
1313

1414
/**
1515
* Applies import manager changes, and writes them as replacements the

schematics/bundles/change_tracker-CDJPOAni.js renamed to schematics/bundles/change_tracker-B4nbMgrL.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use strict';
22
/**
3-
* @license Angular v20.1.0-next.0+sha-310e5ff
3+
* @license Angular v20.1.0-next.0+sha-2c17145
44
* (c) 2010-2025 Google LLC. https://angular.io/
55
* License: MIT
66
*/
77
'use strict';
88

99
var ts = require('typescript');
10-
require('./compiler-BSv6JWRF.js');
11-
var checker = require('./checker-BAl7CJ0l.js');
10+
require('./compiler-COFP8tds.js');
11+
var checker = require('./checker-CrYP6hli.js');
1212
require('os');
1313

1414
/** Tracks changes that have to be made for specific files. */

schematics/bundles/checker-BAl7CJ0l.js renamed to schematics/bundles/checker-CrYP6hli.js

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict';
22
/**
3-
* @license Angular v20.1.0-next.0+sha-310e5ff
3+
* @license Angular v20.1.0-next.0+sha-2c17145
44
* (c) 2010-2025 Google LLC. https://angular.io/
55
* License: MIT
66
*/
77
'use strict';
88

9-
var compiler = require('./compiler-BSv6JWRF.js');
9+
var compiler = require('./compiler-COFP8tds.js');
1010
var ts = require('typescript');
1111
require('os');
1212
var fs$1 = require('fs');
@@ -171,6 +171,10 @@ exports.ErrorCode = void 0;
171171
* class used as a component).
172172
*/
173173
ErrorCode[ErrorCode["INCORRECT_NAMED_TEMPLATE_DEPENDENCY_TYPE"] = 2025] = "INCORRECT_NAMED_TEMPLATE_DEPENDENCY_TYPE";
174+
/**
175+
* Raised for `@Component` fields that aren't supported in a selectorless context.
176+
*/
177+
ErrorCode[ErrorCode["UNSUPPORTED_SELECTORLESS_COMPONENT_FIELD"] = 2026] = "UNSUPPORTED_SELECTORLESS_COMPONENT_FIELD";
174178
ErrorCode[ErrorCode["SYMBOL_NOT_EXPORTED"] = 3001] = "SYMBOL_NOT_EXPORTED";
175179
/**
176180
* Raised when a relationship between directives and/or pipes would cause a cyclic import to be
@@ -1000,7 +1004,7 @@ class NodeJSPathManipulation {
10001004
// G3-ESM-MARKER: G3 uses CommonJS, but externally everything in ESM.
10011005
// CommonJS/ESM interop for determining the current file name and containing dir.
10021006
const isCommonJS = typeof __filename !== 'undefined';
1003-
const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('checker-BAl7CJ0l.js', document.baseURI).href));
1007+
const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('checker-CrYP6hli.js', document.baseURI).href));
10041008
const currentFileName = isCommonJS ? __filename : url.fileURLToPath(currentFileUrl);
10051009
/**
10061010
* A wrapper around the Node.js file-system that supports readonly operations and path manipulation.
@@ -7308,6 +7312,7 @@ exports.ComponentScopeKind = void 0;
73087312
(function (ComponentScopeKind) {
73097313
ComponentScopeKind[ComponentScopeKind["NgModule"] = 0] = "NgModule";
73107314
ComponentScopeKind[ComponentScopeKind["Standalone"] = 1] = "Standalone";
7315+
ComponentScopeKind[ComponentScopeKind["Selectorless"] = 2] = "Selectorless";
73117316
})(exports.ComponentScopeKind || (exports.ComponentScopeKind = {}));
73127317

73137318
/**
@@ -12284,7 +12289,7 @@ class OutOfBandDiagnosticRecorderImpl {
1228412289
`Cannot find name "${node instanceof compiler.Directive ? node.name : node.componentName}".`));
1228512290
}
1228612291
incorrectTemplateDependencyType(id, node) {
12287-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.startSourceSpan, ts.DiagnosticCategory.Error, ngErrorCode(exports.ErrorCode.INCORRECT_NAMED_TEMPLATE_DEPENDENCY_TYPE), `Incorrect reference type. Type must be an ${node instanceof compiler.Component ? '@Component' : '@Directive'}.`));
12292+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.startSourceSpan, ts.DiagnosticCategory.Error, ngErrorCode(exports.ErrorCode.INCORRECT_NAMED_TEMPLATE_DEPENDENCY_TYPE), `Incorrect reference type. Type must be a standalone ${node instanceof compiler.Component ? '@Component' : '@Directive'}.`));
1228812293
}
1228912294
unclaimedDirectiveBinding(id, directive, node) {
1229012295
const errorMsg = `Directive ${directive.name} does not have an ` +
@@ -15140,7 +15145,7 @@ class Scope {
1514015145
const directives = this.tcb.boundTarget.getDirectivesOfNode(directive);
1514115146
if (directives === null ||
1514215147
directives.length === 0 ||
15143-
directives.some((dir) => dir.isComponent)) {
15148+
directives.some((dir) => dir.isComponent || !dir.isStandalone)) {
1514415149
this.tcb.oobRecorder.incorrectTemplateDependencyType(this.tcb.id, directive);
1514515150
continue;
1514615151
}
@@ -15213,7 +15218,7 @@ class Scope {
1521315218
const directives = this.tcb.boundTarget.getDirectivesOfNode(node);
1521415219
if (directives === null ||
1521515220
directives.length === 0 ||
15216-
directives.every((dir) => !dir.isComponent)) {
15221+
directives.every((dir) => !dir.isComponent || !dir.isStandalone)) {
1521715222
this.tcb.oobRecorder.incorrectTemplateDependencyType(this.tcb.id, node);
1521815223
return;
1521915224
}
@@ -17476,12 +17481,19 @@ class TemplateTypeCheckerImpl {
1747617481
return builder;
1747717482
}
1747817483
getPotentialTemplateDirectives(component) {
17484+
const scope = this.getComponentScope(component);
17485+
// Don't resolve directives for selectorless components since they're already in the file.
17486+
if (scope?.kind === exports.ComponentScopeKind.Selectorless) {
17487+
return [];
17488+
}
1747917489
const typeChecker = this.programDriver.getProgram().getTypeChecker();
17480-
const inScopeDirectives = this.getScopeData(component)?.directives ?? [];
1748117490
const resultingDirectives = new Map();
17482-
// First, all in scope directives can be used.
17483-
for (const d of inScopeDirectives) {
17484-
resultingDirectives.set(d.ref.node, d);
17491+
if (scope !== null) {
17492+
const inScopeDirectives = this.getScopeData(component, scope)?.directives ?? [];
17493+
// First, all in scope directives can be used.
17494+
for (const d of inScopeDirectives) {
17495+
resultingDirectives.set(d.ref.node, d);
17496+
}
1748517497
}
1748617498
// Any additional directives found from the global registry can be used, but are not in scope.
1748717499
// In the future, we can also walk other registries for .d.ts files, or traverse the
@@ -17500,12 +17512,19 @@ class TemplateTypeCheckerImpl {
1750017512
return Array.from(resultingDirectives.values());
1750117513
}
1750217514
getPotentialPipes(component) {
17515+
const scope = this.getComponentScope(component);
17516+
// Don't resolve pipes for selectorless components since they're already in the file.
17517+
if (scope?.kind === exports.ComponentScopeKind.Selectorless) {
17518+
return [];
17519+
}
1750317520
// Very similar to the above `getPotentialTemplateDirectives`, but on pipes.
1750417521
const typeChecker = this.programDriver.getProgram().getTypeChecker();
17505-
const inScopePipes = this.getScopeData(component)?.pipes ?? [];
1750617522
const resultingPipes = new Map();
17507-
for (const p of inScopePipes) {
17508-
resultingPipes.set(p.ref.node, p);
17523+
if (scope !== null) {
17524+
const inScopePipes = this.getScopeData(component, scope)?.pipes ?? [];
17525+
for (const p of inScopePipes) {
17526+
resultingPipes.set(p.ref.node, p);
17527+
}
1750917528
}
1751017529
for (const pipeClass of this.localMetaReader.getKnown(exports.MetaKind.Pipe)) {
1751117530
const pipeMeta = this.metaReader.getPipeMetadata(new Reference(pipeClass));
@@ -17669,16 +17688,15 @@ class TemplateTypeCheckerImpl {
1766917688
}
1767017689
return imports;
1767117690
}
17672-
getScopeData(component) {
17673-
if (this.scopeCache.has(component)) {
17674-
return this.scopeCache.get(component);
17675-
}
17691+
getComponentScope(component) {
1767617692
if (!isNamedClassDeclaration(component)) {
1767717693
throw new Error(`AssertionError: components must have names`);
1767817694
}
17679-
const scope = this.componentScopeReader.getScopeForComponent(component);
17680-
if (scope === null) {
17681-
return null;
17695+
return this.componentScopeReader.getScopeForComponent(component);
17696+
}
17697+
getScopeData(component, scope) {
17698+
if (this.scopeCache.has(component)) {
17699+
return this.scopeCache.get(component);
1768217700
}
1768317701
const dependencies = scope.kind === exports.ComponentScopeKind.NgModule
1768417702
? scope.compilation.dependencies

0 commit comments

Comments
 (0)