This fix is for a bug in the ngtsc PartialEvaluator, which statically evaluates expressions. Sometimes, evaluating a reference requires resolving a function which is declared in another module, and thus no function body is available. To support this case, the PartialEvaluator has the concept of a foreign function resolver. This allows the interpretation of expressions like: const router = RouterModule.forRoot([]); even though the definition of the 'forRoot' function has no body. In ngtsc today, this will be resolved to a Reference to RouterModule itself, via the ModuleWithProviders foreign function resolver. However, the PartialEvaluator also associates any Identifiers in the path of this resolution with the Reference. This is done so that if the user writes const x = imported.y; 'x' can be generated as a local identifier instead of adding an import for 'y'. This was at the heart of a bug. In the above case with 'router', the PartialEvaluator added the identifier 'router' to the Reference generated (through FFR) to RouterModule. This is not correct. References that result from FFR expressions may not have the same value at runtime as they do at compile time (indeed, this is not the case for ModuleWithProviders). The Reference generated via FFR is "synthetic" in the sense that it's constructed based on a useful interpretation of the code, not an accurate representation of the runtime value. Therefore, it may not be legal to refer to the Reference via the 'router' identifier. This commit adds the ability to mark such a Reference as 'synthetic', which allows the PartialEvaluator to not add the 'router' identifier down the line. Tests are included for both the PartialEvaluator itself as well as the resultant buggy behavior in ngtsc overall. PR Close #29387
build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that downstream angular build uses angular bundles (#28871)
build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that downstream angular build uses angular bundles (#28871)
build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that downstream angular build uses angular bundles (#28871)
Angular
Angular is a development platform for building mobile and desktop web applications using Typescript/JavaScript and other languages.
Quickstart
Changelog
Learn about the latest improvements.
Want to help?
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the hotlist: community-help.
Description
Languages
TypeScript
68.6%
HTML
12.8%
JavaScript
8.4%
Pug
7%
Starlark
1.4%
Other
1.7%