mirror of
https://github.com/angular/angular.git
synced 2026-11-23 07:05:14 -05:00
In local compilation mode the compiler can emit a reference to a symbol that it
was not able to prove has a value at runtime, because deciding that can require
information from other files. The generated factory already guards those
references with a `@ts-ignore`, but the `ctorParameters` callback passed to
`setClassMetadata` does not, so the same symbol ends up guarded in one place and
unguarded a few lines later in the same file. Type checking the generated code
then fails on the unguarded reference.
Constructor parameters are now handed to `@angular/compiler` in a structured
form rather than as an already-built callback, which lets the compiler attach a
suppression directly to the `type` property assignment of each parameter that
needs one. Only references that reflection could not verify are guarded: full
compilation resolves every reference, so its output is unchanged, and partial
declarations are published as JavaScript and never type checked, so they are
never guarded either.
Producers that build the callback themselves keep passing an expression, which
is emitted untouched.
(cherry picked from commit c92ed082ea)
Angular Linker
This package contains a FileLinker and supporting code to be able to "link" partial declarations of components, directives, etc in libraries to produce the full definitions.
The partial declaration format allows library packages to be published to npm without exposing the underlying Ivy instructions.
The tooling here allows application build tools (e.g. CLI) to produce fully compiled components, directives, etc at the point when the application is bundled.
These linked files can be cached outside node_modules so it does not suffer from problems of mutating packages in node_modules.
Generally this tooling will be wrapped in a transpiler specific plugin, such as the provided Babel plugin.
Unit Testing
The unit tests are built and run using Bazel:
pnpm bazel test //packages/compiler-cli/linker/test