There was a subtle bug involving the opt-out class for FormBuilder, which I discovered during the ongoing migration. The types must be structurally the same, because people pass around FormBuilders, in addition to passing around the controls they produce. This PR ensures FormBuilder and UntypedFormBuilder are assignable to each other.
PR Close#45421
In early versions of Angular, it was sometimes necessary to provide a
`moduleId` to `@Component` metadata, and the common pattern for doing this
was to set `moduleId: module.id`. This relied on the bundler to fill in a
value for `module.id`.
However, due to the superficial similarity between `Component.moduleId` and
`NgModule.id`, many users ended up setting `id: module.id` in their
NgModules. This is an anti-pattern that has a few negative effects,
including preventing the NgModule from tree-shaking properly.
This commit changes the compiler to ignore `id: module.id` in NgModules, and
instead provide a warning which suggests removing the line entirely.
PR Close#45024
Previously, the `TraitCompiler` would naively consider a compilation as
failed if either analysis or resolution produced any diagnostics. This
commit adjusts the logic to only consider error diagnostics, which allows
warnings to be produced from `DecoratorHandler`s.
This is a precursor commit to introducing such a warning. As such, the
logic here will be tested in the next commit.
PR Close#45024
Angular contains an NgModule registry, which allows a user to declare
NgModules with string ids and retrieve them via those ids, using the
`getNgModuleById` API.
Previously, we attempted to structure this registration in a clever fashion
to allow for tree-shaking of registered NgModules (that is, those with ids).
This sort of worked due to the accidental alignment of behaviors from the
different tree-shakers involved. However, this trick relies on the
generation of `.ngfactory` files and how they're specifically processed in
various bundling scenarios. We intend to remove `.ngfactory` files, hence
we can no longer rely on them in this way.
The correct solution here is to recognize that `@NgModule({id})` is
inherently declaring a global side-effect, and such classes should not
really be eligible for tree-shaking in the first place. This commit removes
all the old registration machinery, and standardizes on generating a side-
effectful call to `registerNgModuleType` for NgModules that have ids.
There is some risk here that NgModules with unnecessary `id`s may not
tree-shake as a result of this change, whereas they would have in previous
circumstances. The fix here should be to remove the `id` if it's not needed.
Specifying an `id` is a request that the NgModule be retained regardless of
any other references, in case it is later looked up by string id.
PR Close#45024
When `@angular/compiler` processes metadata and compiles a definition field,
it might also choose to return statements that are associated with that
definition, and should be included after the type being compiled. Currently,
the linker ignores these statements, as there are none generated that are
relevant in the linking operation.
A challenge to supporting such associated statements is that the linker
operates on "declare" expressions, and replaces those expressions with other
expressions. It does not have the capability to append statements after the
whole type. The linker actually faces this challenge with statements from
the `ConstantPool` as well, and solves this problem by generating an IIFE
expression that executes the statements and then returns the definition
expression.
Previously, an `EmitScope` processed the definition and converted it to an
expression, as well as collected constant statements from a `ConstantPool`.
A special `IifeEmitScope` implementation was used when emitting into a
context where top-level constant statements couldn't be added at all, and
uses the IIFE strategy in this case.
This commit adds blanket support for associated statements to the linker
using this IIFE strategy. The main `EmitScope` now uses the IIFE strategy to
emit associated statements, and `IifeEmitScope` has been renamed to
`LocalEmitScope`. Now, the `LocalEmitScope` represents constant statements
as associated statements to the main `EmitScope` implementation, so they
get included in the IIFE as well.
Tests are adjusted/added to cover this new behavior. This is a refactoring
commit because no live generated code is affected - there are no cases where
associated statements are present in linked definitions today.
PR Close#45024
The `compileNgModule` operation previously supported a flag `emitInline`,
which controlled whether template scoping information for the NgModule was
emitted directly into the compiled NgModule definition, or whether an
associated statement was generated which patched the information onto the
NgModule definition. Both options are useful in different contexts.
This commit changes this flag to an enum (and renames it), which allows for
a third option - do not emit any template scoping information. This option
is added to better represent the actual behavior of the Angular Linker,
which sometimes configures `compileNgModule` to use the side-effectful
statement generation but which does not actually emit such associated
statements. In other words, the linker effectively does not generate
scoping information for NgModules at all (in some configurations) and this
option more directly expresses that behavior.
This is a refactoring as no generated code is changed as a result of
introducing this flag, due to the linker's behavior of not emitting
associated statements.
PR Close#45024
Previously, the migration only migrated constructor calls. Now, the migration will rewrite every usage, in all contexts. Both ways are technically correct, but migrating all symbols is likely to produce clearer and more readable results.
PR Close#45311
warn developers when they are trying to animate non-animatable CSS
properties so that can more easily understand why something is not being
animated as they would expect it to
resolves#27577
PR Close#45212
Move to the CircleCI v2 api as the authentication fails for downloading artifacts using the v1 methods.
CircleCI v2 api now requires authentication to occur view the headers instead of being done in a
query parameter, all of the CircleCI interactions are now performed through one fetchFromCircleCi method
which ensures the token is provided in the headers as expected.
PR Close#45349
The animations package supports adding default parameter values to an animation that will be used as a fallback if some parameters aren't defined. The problem is that they're applied using a spread expression which means that any own property of the animation parameters will override the defaults, even if it resolves to null or undefined. This can lead to obscure errors like "Cannot read property toString of undefined" for an animation that looks like `{params: {foo: undefined}}` with defaults `{foo: 123}`.
I ran into this issue while debugging some test failures on Material.
These changes address the issue by:
1. Applying the defaults if the resolved value is null or undefined.
2. Updating the validation function to use a null check instead of `hasOwnProperty`.
PR Close#45339
The underlying parser that the CLI uses changed which caused minor changes in the generated JSON helps especially for subcommands.
The folder structure of the Angular CLI repo also changed slightly.
More context: https://github.com/angular/angular-cli/pull/22778
PR Close#45225
* `tree` function now accepts the old root rather than the old
`UrlTree`. The `urlTree` argument was only used to get the `root`.
This change makes it more clear what that pararmeter is used for and
what's actually being used
* Move the `oldRoot` (previously `urlTree`) to be the first argument of `tree`.
This change now mirrors the argument order for `replaceSegment` and
can be read from left to right more easily "in this root,
replace this old segment group with this new segment group".
* Extract `newRoot` to a variable. This just makes it more clear what's
going on at the end rather than combining a bunch of operations into
one.
These changes are being made so that hopefully a future refactor can be
done which does not rely on the `urlTree` argument at all in the
`createUrlTree` function. These refactorings will make it easier to see
1:1 functionlity in these various places.
PR Close#45306
Changes <div> to <p> in description to match the elements in the screenshot.
Update lifecycle-hooks.md
Changes <div> to <p> in description to match the elements in the screenshot.
PR Close#45063
Close#44724
`DebugNode.triggerEventHandler()` should accept the `eventObj` as an
optional parameter. So the user don't have to write code like
```
elem.triggerEventHandler('click', null);
```
PR Close#45279
When authoring Angular templates, developers are likely to be most interested in
the current Directive/Component inputs and outputs, then potential
attributes which would match other directives to the element,
and lastly the plethora of DOM events and attributes.
This change ensures that Angular-specific information appears above DOM
information by prepending the first printable ASCII characters to the
sort text.
Fixes https://github.com/angular/vscode-ng-language-service/issues/1537
PR Close#45293
ZoneJS has been updated as part of the lock file refresh by Renovate. The
polyfills bundle reduced in size by around 4k which is due to some code
simplication in ZoneJS being finally released. This is the commit responsible
for the major reduction (also mentioning the reduction):
0f298a13db
PR Close#45289