Commit graph

30709 commits

Author SHA1 Message Date
Paul Gschwendtner
bbc970bb0b refactor(migrations): always add readonly to migrated signal inputs (#57368)
Signal inputs are no longer updated by assignment, unlike `@Input()`, so
a good practice is adding `readonly` for the `InputSignal`— which should
never be swapped out.

This is a safe operation because the migration skips all inputs that are
being written anyway.

PR Close #57368
2024-08-13 09:41:09 -07:00
Paul Gschwendtner
87d00d26ff refactor(migrations): use input() shorthand if possible in input migration (#57368)
In some cases, the migration can detect when `input()` as a shorthand
may be usable. This commit adds such detection and migrates inputs to
this form when possible.

PR Close #57368
2024-08-13 09:41:08 -07:00
Matthieu Riegler
84752069f2 docs(docs-infra): Update marked to 14 (#57363)
This is a backport of the marked update and the fix that went with it (#57338)

PR Close #57363
2024-08-13 09:33:04 -07:00
Angular Robot
d3b46ade94 build: update scorecard action dependencies (#57358)
See associated pull request for more information.

PR Close #57358
2024-08-13 09:30:16 -07:00
Angular Robot
1828d11d84 build: update dependency @babel/core to v7.25.2 (#57191)
See associated pull request for more information.

PR Close #57191
2024-08-13 09:29:35 -07:00
Paul Gschwendtner
b8c82fa2f7 refactor(migrations): handle jit: true component templates in signal input migration (#57347)
Components with `jit: true` are not processed by the Angular compiler,
so we cannot ask the template checker for the parsed template; simply
because the template wasn't attempted to be parsed.

We still can migrate simple cases of such components, commonly seen in
unit tests. We do this by manually parsing the template and making use
of the reference fallback resolution that is also used for host bindings
(where we don't have any type check block information).

PR Close #57347
2024-08-12 15:17:41 -07:00
Paul Gschwendtner
fa77c9e5b4 refactor(migrations): expose angular compiler options to signal input migration (#57347)
Instead of exposing just the `ts.CompilerOptions`, we should expose the
actual Angular compiler options throuhgout the signal input migration.

This will be useful for parsing templates, in cases of JIT-opted
components.

PR Close #57347
2024-08-12 15:17:40 -07:00
Paul Gschwendtner
5d16c286bf refactor(migrations): handle safe property reads in signal input migration (#57318)
As of this commit, the migration will also inspect safe property reads
and migrate them, if they reference an input that is being migrated.

PR Close #57318
2024-08-12 12:12:23 -07:00
Paul Gschwendtner
604270619a perf(migrations): speed up signal input migration by combining two analyze phases (#57318)
Instead of revisiting each source file, and each of its child nodes
twice, we now visit them together using a grouped AST visitor that only
traverses each source file once.

This seemed to speed up migration by 6-8% locally, but is likely
noticable better with large compilation scopes.

PR Close #57318
2024-08-12 12:12:23 -07:00
Paul Gschwendtner
1b546975f0 refactor(migrations): use import manager in signal input migration (#57318)
Instead of fiddling manually with the imports, which worked well, but
comes at a cost of complexity— we are now using the canonical import
manager. This simplifies deletion, insertion and updating of imports.

Notably, our import manager is not super great at preserving whitespaces
right now, but we assume a formatter runs over migrated code anyway.

PR Close #57318
2024-08-12 12:12:23 -07:00
Paul Gschwendtner
16ae748257 refactor(migrations): add best effort mode to signal input migration (#57318)
Introduces a best effort mode for the signal input migration. This mode
can be used to aggresively migrate as much as possible, ignoring most
of the incompatibility reasons, like "writes to the input".

PR Close #57318
2024-08-12 12:12:22 -07:00
Paul Gschwendtner
ecb0f8f161 refactor(migrations): add initial docs for signal input migration incompatibility reasons (#57318)
Adds a markdown document capturing some of the incompatibilty reasons
on why the input wasn't migrated.

PR Close #57318
2024-08-12 12:12:22 -07:00
Gilad Mautner
cea3e4b594 docs: reorder afterView and afterContent related lifecycle hooks (#57307)
PR Close #57307
2024-08-09 13:55:39 -07:00
Paul Gschwendtner
448279f57e refactor(migrations): detect if an input is not narrowed and can be migrated (#57308) (#57323)
By default, we don't migrate inputs if they are part of e.g. `@if` for
now. That is because we don't have the template narrowing feature
available yet.

To improve impact of the migration until we have the narrowing, we add
some additional checks that allow us to migrate instances of inputs that
are part of e.g. `@if` but are actually not used inside (and hence are
guaranteed to be _not_ narrowed).

PR Close #57308

PR Close #57323
2024-08-09 12:17:34 -07:00
Andrew Kushnir
5558e275ee fix(core): take skip hydration flag into account while hydrating i18n blocks (#57299)
This commit updates serialization and hydration i18n logic to take into account situations when i18n blocks are located within "skip hydration" blocks.

Resolves #57105.

PR Close #57299
2024-08-09 08:07:49 -07:00
Andrew Kushnir
86216792fd fix(core): complete post-hydration cleanup in components that use ViewContainerRef (#57300)
Previously, if a component injects a `ViewContainerRef`, the post-hydration cleanup process doesn't visit inner views to cleanup dehydrated views in nested LContainers. This commit updates the logic to recognize this situation and enter host LView to complete cleanup.

Resolves #56989.

PR Close #57300
2024-08-09 08:07:13 -07:00
Kristiyan Kostadinov
cab6c23602 refactor(migrations): add internal cleanup logic (#57315)
Expands the `inject` migration to add some cleanups that are only relevant internally. Externally this isn't exposed to users.

PR Close #57315
2024-08-09 08:02:34 -07:00
Andrew Scott
296216cbe1 fix(core): Allow hybrid CD scheduling to support multiple "Angular zones" (#57267)
This commit updates the inside/outside NgZone detection of the hybrid CD
scheduling to track the actual instance of the NgZone being used rather
than the name "Angular" (how `isInsideAngularZone` works). This allows
the scheduling to work correctly when there are multiple versions of
Angular running on the page.

fixes #57261

PR Close #57267
2024-08-08 10:46:26 -07:00
Thomas Nguyen
9af760eb51 fix(core): Account for addEventListener to be passed a Window or Document. (#57282)
This happened to work for other event listeners since both had a
addEventListener method.

PR Close #57282
2024-08-08 08:32:11 -07:00
Kristiyan Kostadinov
b16dd6d67f fix(compiler-cli): generate valid TS 5.6 type checking code (#57303)
Currently in some scenarios the compiler generates code like `null as any ? foo : bar` which will be invalid with [an upcoming TypeScript change](https://devblogs.microsoft.com/typescript/announcing-typescript-5-6-beta/#disallowed-nullish-and-truthy-checks). These changes switch to generating `0 as any` which is exempt from the change.

**Note:** I'm not starting the work to fully get us on TS 5.6 until the 18.2 release comes out, but this change is necessary to unblock an internal team.

PR Close #57303
2024-08-08 08:30:13 -07:00
Jessica Janiuk
02d613ef9c release: cut the v18.2.0-rc.0 release 2024-08-07 12:27:07 -07:00
Jessica Janiuk
ccbce8ffba docs: release notes for the v18.1.4 release 2024-08-07 11:54:15 -07:00
Paul Gschwendtner
07ec04d49d refactor(migrations): improve temporary variable generation for input migration (#57292)
This changes the migration so that we don't generate `_1` suffixes when
a temporary variable wouldn't conflict with any variables in the lexical
scope.

In addition, if we discover conflicts, we try alternative suffixes that
seem more natural and follow style guides. E.g. `Value`, `Val` or
`Input`.

PR Close #57292
2024-08-07 18:26:07 +00:00
Matthieu Riegler
e1240c6f5d fix(zone.js): Add support for addition jest functions. (#57280)
This commit add support for `test.failing` and `it.failing`.

Fixes #57277

PR Close #57280
2024-08-07 18:13:51 +00:00
Kristiyan Kostadinov
d9d68e73d2 fix(compiler): reduce chance of conflicts between generated factory and local variables (#57181)
Currently we use some short variable names like `t` and `r` in the generated factory functions. They can conflict with local symbols with the same names, if they're used for DI.

These changes rename the parameters to reduce the change for conflicts.

Fixes #57168.

PR Close #57181
2024-08-07 17:25:05 +00:00
JoostK
0b1dd39663 perf(compiler-cli): improve performance of interpolatedSignalNotInvoked extended diagnostic (#57291)
This commit addresses a performance bottleneck in the `interpolatedSignalNotInvoked` extended
diagnostic by querying directive metadata instead of consulting the type-checker to determine if
a property binding corresponds with an input.

Fixes #57287

PR Close #57291
2024-08-07 16:47:24 +00:00
Kristiyan Kostadinov
513a4fe05e refactor(core): replace usages of removeChild (#57203)
These changes replace most usages of `removeChild` with `remove`. The latter has the advantage of not having to look up the `parentNode` and ensure that the child being removed actually belongs to the specific parent.

The refactor should be fairly safe since all the browsers we cover support `remove`. [Something similar was done in Components](https://github.com/angular/components/pull/23592) some time ago and there haven't been any bug reports as a result.

PR Close #57203
2024-08-07 16:46:09 +00:00
David LJ
d465061f00 docs(router): update initial navigation SSR note (#57245)
With rephrasing by @AndrewKushnir

PR Close #57245
2024-08-07 16:45:30 +00:00
Andrew Scott
7919982063 feat(core): Add whenStable helper on ApplicationRef (#57190)
This commit adds a `whenStable` function to `ApplicationRef` to cover
the most common use-case for the `isStable` observable.

PR Close #57190
2024-08-06 21:28:16 +00:00
Angular Robot
f9a97c710d build: update actions/upload-artifact action to v4.3.5 (#57271)
See associated pull request for more information.

PR Close #57271
2024-08-06 13:50:52 +00:00
Angular Robot
722ae984c0 build: update actions/upload-artifact action to v4.3.5 (#57270)
See associated pull request for more information.

PR Close #57270
2024-08-06 13:50:11 +00:00
Andrew Scott
15a8495211 refactor(docs-infra): Use new APIs in search dialog (#57269)
This reverts commit 9109f31cb7.

PR Close #57269
2024-08-06 13:49:41 +00:00
Andrew Scott
9109f31cb7 Revert "refactor(docs-infra): Use new APIs in search dialog (#57215)" (#57268)
This reverts commit f5960d0f94.

PR Close #57268
2024-08-05 21:11:59 +00:00
Andrew Scott
70e8b40750 fix(zone.js): Update the default behavior of fakeAsync to flush after the test (#57240)
From the internal issue on the matter:

> When using the standard Jasmine version of it promises returned by the body function are automatically awaited. The Catalyst version of it is fake-async, so awaiting the promise does not make sense; however it would be nice if Catalyst automatically flushed the promise to replicate the experience of using standard it. This would allow users to do the following:

```
it('should fail later', async () => {
  await new Promise(r => setTimeout(r));
  fail('failure');
});
```
> In Catalyst today the above test will pass. If this proposal to automatically flush the resulting promise were implemented it would fail.

Flushing after the tests complete has been the default behavior inside
Google since 2020. Very few tests remain that use the old behavior of
only flushing microtasks. The example above would actually fail with
`fakeAsync` due to the pending timer, but the argument still remains the
same. We might as well just flush if we're going to fail the test
anyways by throwing if there's no flush at the end.

BREAKING CHANGE: `fakeAsync` will now flush pending timers at the end of
the given function by default. To opt-out of this, you can use `{flush:
false}` in options parameter of `fakeAsync`

PR Close #57240
2024-08-05 20:24:54 +00:00
Andrew Scott
a55ecb9429 build: update zone.js version to 0.14.10 instead of 0.15 (#57266)
this fixes the  version of zone.js in the package deps

PR Close #57266
2024-08-05 18:15:41 +00:00
Andrew Scott
f7918f5272 feat(core): Add 'flush' parameter option to fakeAsync to flush after the test (#57239)
From the internal issue on the matter:

> When using the standard Jasmine version of it promises returned by the body function are automatically awaited. The Catalyst version of it is fake-async, so awaiting the promise does not make sense; however it would be nice if Catalyst automatically flushed the promise to replicate the experience of using standard it. This would allow users to do the following:

```
it('should fail later', async () => {
  await new Promise(r => setTimeout(r));
  fail('failure');
});
```
> In Catalyst today the above test will pass. If this proposal to automatically flush the resulting promise were implemented it would fail.

Flushing after the tests complete has been the default behavior inside
Google since 2020. Very few tests remain that use the old behavior of
only flushing microtasks. The example above would actually fail with
`fakeAsync` due to the pending timer, but the argument still remains the
same. We might as well just flush if we're going to fail the test
anyways by throwing if there's no flush at the end.

PR Close #57239
2024-08-05 17:46:04 +00:00
Jessica Janiuk
4d0842d546 release: cut the v18.2.0-next.4 release 2024-08-05 10:34:05 -07:00
Joey Perrott
3bdead1b2f refactor(docs-infra): migrate api-gen from dev-infra into the repo (#57241)
Move the api-gen pipeline into the shared-docs directory.

PR Close #57241
2024-08-05 17:06:29 +00:00
Jessica Janiuk
de99d3eb3e release: cut the zone.js-0.14.10 release (#57264)
PR Close #57264
2024-08-05 17:00:06 +00:00
Angular Robot
00a6c41129 build: update dependency madge to v8 (#57257)
See associated pull request for more information.

PR Close #57257
2024-08-05 15:58:03 +00:00
Paul Gschwendtner
e2259c7b09 fix(compiler-cli): support JIT transforms before other transforms modifying classes (#57262)
Similar to a previous fix that intended to make the JIT transforms
compatible with pre-transforms like e.g. Tsickle, we need to solve
an additional issue where the class properties are synthetic and result
in an `getSourceFile() => undefined` invocation that breaks the import
insertion, causing errors like:

```
TypeError: Cannot read properties of undefined (reading 'fileName')
```

PR Close #57262
2024-08-05 14:45:19 +00:00
Angular Robot
dbca467a35 build: lock file maintenance (#57256)
See associated pull request for more information.

PR Close #57256
2024-08-05 14:42:24 +00:00
Doug Parker
9aa94eb0e3 release: bump Angular DevTools to 1.0.17 (#57221)
PR Close #57221
2024-08-02 16:53:13 +00:00
Doug Parker
bd953c7847 docs(devtools): remove duplicate text at end of release.md doc (#57222)
Somehow the last few lines got duplicated at the end of this doc. Definitely not needed.

PR Close #57222
2024-08-02 16:52:41 +00:00
Andrew Scott
99d679d606 feat(zone.js): Add 'flush' parameter option to fakeAsync to flush after the test (#57137)
From the internal issue on the matter:

> When using the standard Jasmine version of it promises returned by the body function are automatically awaited. The Catalyst version of it is fake-async, so awaiting the promise does not make sense; however it would be nice if Catalyst automatically flushed the promise to replicate the experience of using standard it. This would allow users to do the following:

```
it('should fail later', async () => {
  await new Promise(r => setTimeout(r));
  fail('failure');
});
```
> In Catalyst today the above test will pass. If this proposal to automatically flush the resulting promise were implemented it would fail.

Flushing after the tests complete has been the default behavior inside
Google since 2020. Very few tests remain that use the old behavior of
only flushing microtasks. The example above would actually fail with
`fakeAsync` due to the pending timer, but the argument still remains the
same. We might as well just flush if we're going to fail the test
anyways by throwing if there's no flush at the end.

PR Close #57137
2024-08-02 16:52:07 +00:00
Andrew Scott
827070e331 fix(core): Do not run image performance warning checks on server (#57234)
These checks require document so they should not be run on the server.

PR Close #57234
2024-08-02 15:53:29 +00:00
Charles Lyding
4bb9d0f923 fix(language-service): avoid generating TS suggestion diagnostics for templates (#56241)
Angular's template files are not valid TypeScript. Attempting to get suggestion
diagnostics from the underlying TypeScript language service will result in
a large amount of false positives. Only actual TypeScript files should
be analyzed by the underlying TypeScript language service for suggestions.

PR Close #56241
2024-08-02 15:51:35 +00:00
Andrew Scott
6c76c91e15 feat(router): Add defaultQueryParamsHandling to router configuration (#57198)
This commit adds an option to specify the default value for
`queryParamsHandling` in `Router.createUrlTree` when another option is
not specified (or is `null|undefined`).

resolves #12664

PR Close #57198
2024-08-02 15:11:38 +00:00
Thomas Nguyen
2a915d1912 refactor(core): Remove clickmod support from Angular. (#57201)
This was an old feature that mapped shift + click (et al) to "clickmod". This doesn't really make sense to add to Angular, so let's remove it.

PR Close #57201
2024-08-02 14:20:53 +00:00
Jessica Janiuk
d73a3741a2 Revert "fix(compiler): reduce chance of conflicts between generated factory and local variables (#57181)" (#57230)
This reverts commit 67e09404db.

PR Close #57230
2024-08-01 19:33:04 +00:00