angular/packages/compiler-cli/test/ngtsc
JoostK 43050a16de fix(compiler-cli): prevent eliding default imports in incremental recompilations (#41586)
The Angular compiler has to actively keep default import statements
alive if they were only used in type-only positions, but have been
emitted as value expressions for DI purposes. A problem occurred in
incremental recompilations, where the relationship between an identifier
usage and its corresponding default import would not be considered. This
could result in the removal of the default import statement and caused
a `ReferenceError` at runtime.

This commit fixes the issue by storing the association from an
identifier to its default import declaration on the source file itself,
instead of within the `DefaultImportTracker` instance. The
`DefaultImportTracker` instance is only valid for a single compilation,
whereas the association from an identifier to a default import
declaration is valid as long as the `ts.SourceFile` is the same
instance.

A subsequent commit refactor the `DefaultImportTracker` to no longer
be responsible for registering the association, as its lifetime is
conceptually too short to do so.

Fixes #41377

PR Close #41586
2021-04-13 07:37:28 -07:00
..
BUILD.bazel test(compiler-cli): move testing utils to separate package (#39594) 2020-11-17 11:59:56 -08:00
component_indexing_spec.ts refactor(compiler-cli): update to use new file-system interfaces (#40281) 2021-01-08 09:34:44 -08:00
env.ts test(compiler-cli): disable emitDecoratorMetadata in the compiler test environment (#41586) 2021-04-13 07:37:28 -07:00
incremental_error_spec.ts perf(compiler-cli): detect semantic changes and their effect on an incremental rebuild (#40947) 2021-03-08 08:41:22 -08:00
incremental_semantic_changes_spec.ts perf(compiler-cli): detect semantic changes and their effect on an incremental rebuild (#40947) 2021-03-08 08:41:22 -08:00
incremental_spec.ts fix(compiler-cli): prevent eliding default imports in incremental recompilations (#41586) 2021-04-13 07:37:28 -07:00
incremental_typecheck_spec.ts perf(compiler-cli): detect semantic changes and their effect on an incremental rebuild (#40947) 2021-03-08 08:41:22 -08:00
modulewithproviders_spec.ts test(compiler-cli): move testing utils to separate package (#39594) 2020-11-17 11:59:56 -08:00
monorepo_spec.ts test(compiler-cli): move testing utils to separate package (#39594) 2020-11-17 11:59:56 -08:00
ngtsc_spec.ts test(compiler-cli): disable emitDecoratorMetadata in the compiler test environment (#41586) 2021-04-13 07:37:28 -07:00
scope_spec.ts test(compiler-cli): move testing utils to separate package (#39594) 2020-11-17 11:59:56 -08:00
sourcemap_utils.ts fix(compiler-cli): update type castings for JSON.parse usage (#40710) 2021-02-09 10:48:46 -08:00
template_mapping_spec.ts fix(compiler): exclude trailing whitespace from element source spans (#40513) 2021-01-28 08:57:46 -08:00
template_typecheck_spec.ts fix(compiler-cli): preserve user line endings in diagnostic template parse (#40597) 2021-01-29 11:15:17 -08:00