angular-docs-cn/packages/compiler-cli
JoostK 70c3461be3 fix(compiler-cli): use correct module import for types behind a `forwardRef` (#42887)
The static interpreter assumed that a foreign function expression would
have to be imported from the absolute module specifier that was used for
the foreign function itself. This assumption does not hold for the
`forwardRef` foreign function resolver, as that extracts the resolved
expression from the function's argument, which is not behind the
absolute module import of the `forwardRef` function.

The prior behavior has worked for the typical usage of `forwardRef`,
when it is contained within the same source file as where the static
evaluation started. In that case, the resulting reference would
incorrectly have an absolute module guess of `@angular/core`, but the
local identifier emit strategy was capable of emitting the reference
without generating an import using the absolute module guess.

In the scenario where the static interpreter would first have to follow
a reference to a different source that contained the `forwardRef` would
the compilation fail. In that case, there is no local identifier
available such that the absolute module emitter would try to locate the
imported symbol from `@angular/core`. which fails as the symbol is not
exported from there.

This commit fixes the issue by checking whether a foreign expression
occurs in the same source file as the call expression. If it does, then
the absolute module specifier that was used to resolve the call
expression is ignored.

Fixes #42865

PR Close #42887
2021-07-20 11:56:05 -07:00
..
integrationtest refactor(compiler): remove dependency on fs-extra (#41445) 2021-04-05 15:04:50 -07:00
linker refactor(compiler-cli): ensure compatibility with noImplicitOverride (#42512) 2021-07-12 13:11:14 -07:00
ngcc refactor: add override keyword to members implementing abstract declarations (#42512) 2021-07-12 13:11:17 -07:00
src fix(compiler-cli): use correct module import for types behind a `forwardRef` (#42887) 2021-07-20 11:56:05 -07:00
test fix(compiler-cli): use correct module import for types behind a `forwardRef` (#42887) 2021-07-20 11:56:05 -07:00
BUILD.bazel build: use api-golden tool from dev-infra for testing public API (#42688) 2021-06-30 11:43:48 -07:00
index.ts perf(compiler-cli): refactor the performance tracing infrastructure (#41125) 2021-03-24 13:42:24 -07:00
package.json feat(core): support TypeScript 4.3 (#42022) 2021-06-04 11:17:09 -07:00
tsconfig-build.json build: reference zone.js from source directly instead of npm. (#33046) 2019-11-06 00:48:34 +00:00
tsconfig.json perf(ivy): ngcc - only find dependencies when targeting a single entry-point (#30525) 2019-07-09 09:40:46 -07:00