10228 Commits

Author SHA1 Message Date
Kristiyan Kostadinov 56e085f3f8 build: remove Windows CI check (#52140) (#55527)
Based on recent discussions, these changes remove the Windows CI check because it has been too flaky for too long. Furthermore, we've concluded that the simulated file system in the compiler tests already catches the same set of bugs as running the tests on a real Windows system.

PR Close #52140

(cherry picked from commit 5a969e06b7)

PR Close #55527
2024-04-25 08:48:45 -07:00
Alan Agius 4127b29ca7 build: address failures in zone.js typings tests (#55527)
Update zone.js typings tests to work

PR Close #55527
2024-04-25 08:48:45 -07:00
Alex Castle e092184a5c fix(common): apply fixed_srcset_width values only to fixed srcsets (#52486)
fix fixed_srcseet_width being incorrectly applied to responsive srcsets

PR Close #52486
2023-11-02 11:04:25 -07:00
arturovt 03f4050636 fix(animations): remove finish listener once player is destroyed (#51136)
This commit removes the `finish` listener from the Animation object once
the animation is finished, effectively resolving a memory leak. Previously,
the `finish` listener captured `this`, which prevented `this` from being garbage collected.

PR Close #51136
2023-11-02 10:29:41 -07:00
JoostK 873c4f2454 fix(compiler-cli): use originally used module specifier for transform functions (#52437)
Prior to this change, the transform function would be referenced with a potentially
relative import into an external declaration file. Such imports are not portable
and should not be created in this context. This commit addresses the issue by threading
though the originally used module specifier by means of the `Reference` type.

Fixes #52324

PR Close #52437
2023-10-31 13:42:52 -07:00
JoostK b3b4ae4c3a fix(compiler-cli): properly emit literal types in input coercion function arguments (#52437)
This commit fixes an issue where using literal types in the arguments of an input coercion
function could result in emitting invalid output, due to an assumption that TypeScript makes
when emitting literal types. Specifically, it takes the literal's text from its containing
source file, but this breaks when the literal type node has been transplanted into a
different source file. This issue has surfaced in the type-check code generator and is
already being addressed there, so this commit moves the relevant `TypeEmitter` class
from the `typecheck` module to the `translator` module, such that it can be reused for
emitting types in the type translator.

Fixes #51672

PR Close #52437
2023-10-31 13:42:51 -07:00
Susheel Thapa 38b4602f03 docs: fixed typos (#52297)
PR Close #52297
2023-10-25 16:39:06 -07:00
Andrew Scott b79b4aca91 fix(router): RouterTestingHarness should throw if a component is expected but navigation fails (#52357)
The `RouterTestingHarness` should throw an error if the call to `navigateByUrl`
expects a component to be activated but the navigation failed.

fixes #52344

PR Close #52357
2023-10-25 11:04:24 -07:00
AleksanderBodurri 019a0f4c22 fix(core): load global utils before creating platform injector in the standalone case (#52365)
This is needed so that the providers configured on platform creation are picked up by the injector profiler.

PR Close #52365
2023-10-25 10:51:21 -07:00
AleksanderBodurri 78533324dc fix(core): get root and platform injector providers in special cases (#52365)
Previously, because the platform injector does not have a provider container, this API would fail. Now, we account for this case specifically by returning the found providers immediately, without trying to calculate their importpaths.

Also previously, in the case where a boostrapped standalone component did not import any feature modules, the environment injector connected to that bootstrapped component would be the root injector configured by `bootstrapApplication`. This injector is configured through a `providers` array instead of an `imports` array, and also does not have a provider container. Similarly to the platform case, we account this for this by returning the found providers immediately if there is no provider container for our standalone component.

PR Close #52365
2023-10-25 10:51:21 -07:00
AleksanderBodurri 54ea3b65c3 fix(core): emit provider configured event when a service is configured with providedIn (#52365)
Previously this case was missed by the default framework injector profiler. Now in ngDevMode this event emits correctly when a service is configured with `providedIn`. This includes the case where injection tokens are configured with a `providedIn`.

This commit also includes unit tests for this new case in the injector profiler.

PR Close #52365
2023-10-25 10:51:21 -07:00
Alvaro Junqueira 372dd0ab7d docs: the Component import is not being used (#52323)
PR Close #52323
2023-10-25 09:35:22 -07:00
Naaajii 3afee8716d docs(docs-infra): fix codeblock snippet for APP_INITIALIZER (#52354)
fixes broken code snippet for standalone application using APP_INITIALIZER

PR Close #52354
2023-10-25 09:34:47 -07:00
Matthieu Riegler 56c93d02b5 docs(core): fix the language code (#52352)
PR Close #52352
2023-10-25 09:32:18 -07:00
Andrew Scott 1693846a9b test(core): fix test observing broken OnPush checkNoChanges (#52337)
The test is actually observing that OnPush results in a view not being checked
when checkNoChanges runs.

PR Close #52337
2023-10-24 09:21:52 -07:00
Pawel Kozlowski 2820425e38 build: update babel dependencies to v7.23.2 (#52255)
16.2.x version of #52236

PR Close #52255
2023-10-18 15:56:47 +02:00
Paul Gschwendtner d75eaa7375 refactor(core): remove unused helper for setting LView for reactive consumer (#52192)
This code path is never hit because the assignment of the lview happens
in `commitLViewConsumerIfHasProducers`.

PR Close #52192
2023-10-13 14:08:34 +02:00
Miroslav Foltýn 630e906747 docs(router): add clarification for behavior of paramsInheritanceStrategy: 'emptyOnly' (#52170)
Follows up to the https://github.com/angular/angular/issues/52108 which was opened due to the confusion surrounding paramsInheritanceStrategy: 'emptyOnly'.

PR Close #52170
2023-10-13 11:14:22 +02:00
Pawel Kozlowski f52eee8eb2 Revert "refactor(compiler-cli): remove MethodIdentifier type (#49611)" (#52174)
This reverts commit c2b1a242e8.

PR Close #52174
2023-10-12 12:35:49 +02:00
Matthieu Riegler 5f2a33ac58 refactor(compiler-cli): remove MethodIdentifier type (#49611)
`MethodIdentifier` is unused as is `IdentifierKind.Method`. They both can be removed.

PR Close #49611
2023-10-11 12:34:50 -07:00
Matthieu Riegler 51a5baace3 fix(forms): reset() call with null values on nested group (#48830)
Non typed forms allow to pass null to nested groups when calling `formGroup.reset()`, this commit prevent an undefined access.

fixes #20509

PR Close #48830
2023-10-10 15:34:32 -07:00
Thabo 2bfd28c396 docs: correct wording for Directive's decorator host property key description (#51977)
PR Close #51977
2023-10-10 11:22:19 -07:00
Phalgun Vaddepalli d3c9e436a9 docs(core): add an example of configuring APP_INITIALIZER token in context of standalone components (#52084)
docs(core): fix formatting

PR Close #52084
2023-10-10 11:18:37 -07:00
Andrew Scott b732961fc3 fix(language-service): Retain correct language service when ts.Project reloads (#51912)
When the `ts.Project` creates the language service plugin (in this case,
the Angular Language Service), it sets the project's language service to
the new language service returned by the plugin create:
https://sourcegraph.com/github.com/microsoft/TypeScript@b12af0fa2bbd4b015e59adcfb49988cea7f919a1/-/blob/src/server/project.ts?L2035-2044

The project may be reloaded in response to various events, such as a
change to the tsconfig file, which then recreates the plugin. When this
happens, the language service that gets passed to the plugin `create`
function will not be the typescript language service, but rather the
previous instance of the new language service returned by the last call
to `create`.

This commit ensures that subsequent calls to `create` for the
`NgLanguageService` plugin for a project after the first call are able
to retrieve and hold on to the _TypeScript_ language service.

fixes https://github.com/angular/vscode-ng-language-service/issues/1923

PR Close #51912
2023-10-04 11:27:46 -07:00
Matthieu Riegler 966ce9790a fix(service-worker): throw a critical error when handleFetch fails (#51960)
#51885 patched a call site that threw an error but there were 2 others call that needed to be wrapped in the same way by a try/catch.

`initializeFully` is part of the calls in `responseWith(handleFetch)`.

Same #51885, throwing `SwCriticalError`allows the driver to fallback to `safeFetch` and ensure `responseWith` doesn't fail.

Fixes #50378

PR Close #51960
2023-10-04 08:51:07 -07:00
Andrew Scott 334fe60c17 refactor(core): Update view flags so only one number needs adjustment (#51839)
When adding a new view flag, you currently need to adjust the last number of the last
3 flags. All of these share the same number so the shifting ones can just use
the base-10 IndexWithinInitPhaseShift.

PR Close #51839
2023-10-04 07:29:16 -07:00
Joey Perrott 781bb91f43 build: lock file maintenance (#51838)
Update the lock file.

PR Close #51838
2023-10-02 08:15:28 -07:00
Pawel Kozlowski 39a3e34e03 fix(core): allow toSignal calls in reactive context (#51831) (#51892)
This PR moves the Observable subscription of toSignal outside of the
reactive context. As the result the toSignal calls are allowed in the
computed, effect and all other reactive consumers.

This is based on the reasoning that we already allow signals creation
in a reactive context. Plus a similar change was done to the async pipe
in the https://github.com/angular/angular/pull/50522

Fixes #51027

PR Close #51892
2023-09-27 10:30:15 -07:00
Andrew Kushnir 68648ee684 refactor(core): avoid an empty array allocation during hydration (#51917)
This commit updates hydration runtime code to avoid creating an empty array when we can avoid it. Instead, we just check whether the field is `null` directly (without using nullish coalescing).

PR Close #51917
2023-09-27 09:22:50 -07:00
Matthieu Riegler c3d901eacf fix(service-worker): throw a critical error when handleFetch fails (#51885)
On Safari, the cache might fail on methods like `match` with an `Internal error`. Critical errors allows to fallback to `safeFetch()` in the `Driver`.

fixes: #50378

PR Close #51885
2023-09-26 09:10:38 -07:00
Paul Gschwendtner 663703946e fix(bazel): allow setting _enabledBlockTypes angular compiler option (#51862)
We control most flags via Starlark and therefore limit configuration
options via `tsconfig` to a minimum. We do not intend to support the
enabled block types option via Starlark, so this commit allows for
the option to be picked up.

(This is useful for benchmarking the new control flow blocks).

PR Close #51862
2023-09-22 09:51:26 -07:00
Andrew Scott 4ccd845081 refactor(router): Refactor loadChildren callback execution and privately export for SSR (#51818)
This commit refactors the loadChildren callback execution of the router config loader
into a function that can be used with SSR for the purposes of route extraction.

PR Close #51818
2023-09-20 18:34:13 +02:00
Paul Gschwendtner 03127fc870 refactor(core): ensure reactive node constants are considered pure (#51809) (#51813)
Currently when ESBuild bundles an application importing from
`@angular/core`, the signals library will be discovered during
export analysis. ESBuild will come across the constants for the reactive
signal graph- and end up considering some of these as side-effects given
the pattern of using a spread assignment for extending from e.g.
`REACTIVE_NODE` (a similar issue may occur if we e.g. extend from the
computed reactive node).

See more details on the issue: https://github.com/evanw/esbuild/issues/3392

Even though, ESBuild preserves these constants now, and all of its
dependencies— Terser will consider these as side-effect free and
eliminate these constants. This may require multiple passes though, and
might not be sufficient, depending on the chain of reactive node
extensions. E.g. in the signals branch we noticed some constants
unnecessarily being preserved.

PR Close #51809

PR Close #51813
2023-09-18 15:37:13 +02:00
Kristiyan Kostadinov bf1f9a0897 test(compiler): attempt to deflake windows tests (#51804)
Another try at deflaking the tests on Windows. I'm trying a couple of fixes here:
1. I noticed that it's usually the indexer tests that fail during flaky runs. These tests also happen to be the only ones that don't pass in the `files` argument of `NgtscTestEnvironment.setup`. When `files` isn't passed in, we don't hit the file path that sets up the `MockFileSystem`. With these changes I make it so that we always initialize the mock file system.
2. The missing file system error usually comes from the `absoluteFrom` call that initializes the optional `workingDir` argument. My theory is that because it's a default value for an argument, it gets called too early before everything is initialized. These changes move the `absoluteFrom` call further down until it's needed.

PR Close #51804
2023-09-18 10:46:38 +02:00
Paul Gschwendtner 3b46066ff0 refactor: ensure top-level symbols are marked as side-effect free (#51776)
Terser does not treat `Symbol` as side-effect free- so if we end up with
a symbol export being loaded, it will result in the symbol being
retained.

We noticed this in the signals prototyping where symbols exported
from `computed` ended up appearing in symbol bundling tests.

PR Close #51776
2023-09-15 15:53:51 +02:00
JoostK 7b40d74fb4 refactor(core): let reactive node prototypes conform to their type (#51722) (#51772)
This commit adds explicit type annotations to the reactive node prototype objects,
such that the prototypes are type-checked against the interface they are supposed
to (partially) implement. This also allows IDEs to better track usages of reactive
node properties, improving code navigation.

PR Close #51722

PR Close #51772
2023-09-14 12:51:30 +02:00
JoostK 82712f80df fix(core): ensure a consumer drops all its stale producers (#51722) (#51772)
When a producer is no longer used, the consumer has to update its internal data structure
that keeps track of all producers. There used to be an issue where only half of the stale
producers would actually be removed from this data structure, as the intended upper bound
of the number of producers to remove would decrease with each removed producer, therefore
not reaching all producers that should be removed from the data structure.

This commit fixes the issue by truncating the arrays directly, without going through
individual `pop` operations. An assertion that would catch the inconsistent state in
the internal data structures of the signal graph has been introduced.

PR Close #51722

PR Close #51772
2023-09-14 12:51:30 +02:00
Gerald Monaco c700418ab8 refactor(core): delegate afterRender errors to an ErrorHandler (#51711)
Improves the error handling story for after*Render by delegating errors to an ErrorHandler, so that one failure does not break every callback.

PR Close #51711
2023-09-08 14:21:06 -07:00
Gerald Monaco 867b380f64 refactor(core): make AfterRenderEventManager tree-shakable (#51711)
In preparation for adding support for phases to after*Render, which will increase the implementation size, this commit splits out the optional logic so that it can be tree-shaken and dynamically loaded.

PR Close #51711
2023-09-08 14:21:06 -07:00
Kristiyan Kostadinov 975cb05819 build: attempt to deflake windows tests (#51701)
Adds some logic to try and deflake the tests on Windows.

PR Close #51701
2023-09-08 09:28:03 -07:00
Matthieu Riegler 4051930b8c docs: Add info about hydration caching. (#51648)
The docs was missing an important information about caching. Only GET/HEAD requests are cached until `isStable`

PR Close #51648
2023-09-06 15:31:36 +00:00
AleksanderBodurri 1122afd656 refactor(core): implement __ignore_ng_zone__ flag (#51339)
This flag allows message event listeners to prevent callbacks from executing within the NgZone if they contain a special `__ignore_ng_zone__` flag.

This functionality is built with Angular DevTools in mind, where it prevents an infinite change detection loop in inspecting applications that have message event listeners:

CD -> Inspected app emits componentTreeDirty event to DevTools -> DevTools emits event to get new component Tree from Inspected app -> Inspected app message event listener fires -> CD

PR Close #51339
2023-09-05 18:16:33 +00:00
hiepxanh 8ce22ebae3 docs: fix missing information in createComponent (#51493)
PR Close #51493
2023-09-01 16:15:13 +00:00
hiepxanh 137195cd26 docs: add viewContainerRef example (#51573)
PR Close #51573
2023-09-01 16:14:40 +00:00
Joey Perrott af9cd84c13 build: migrate to node 18 (#51609)
Migrate to use node version 18

PR Close #51609
2023-09-01 15:12:44 +00:00
Alex Rickabaugh f56b6555bd refactor(core): switch signals to a refcounting algorithm (#51226)
This commit switches the signals library from a bidirectional symmetric
dependency graph using weak references, to a bidirectional _asymmetric_
graph which uses strong references. This is made possible with a reference
counting algorithm which only tracks producer -> consumer references for
effect-like "live" consumers, preventing memory leaks.

The new algorithm should be simpler and faster than the previous
implementation as weak references are fairly slow to create and traverse.
A tradeoff is that non-live consumers must now poll their producers when
read, as they cannot rely on dirty notifications.

As part of this refactoring, the `ReactiveNode` class is replaced with an
interface instead, and methods are moved to standalone functions. This is
paired with instantiating individual signals/computeds via `Object.create`
against a prototype node which contains static or initial values. This
technique, in conjunction with the rest, greatly improves the performance
of node creation.

PR Close #51226
2023-09-01 14:18:41 +00:00
Pawel Kozlowski 7bb4f9126b refactor(core): remove duplicated access to TView (#51610)
Tiny refactoring to remove repeated field access to LView.

PR Close #51610
2023-09-01 14:18:06 +00:00
Matthieu Riegler b1a3925794 refactor(core): Use intersections on branded types. (#49702)
An Intersection on a branded type allows us to remove some unecessary type assertions.

PR Close #49702
2023-08-31 20:22:12 +00:00
Angular Robot ba46365abd build: update dependency google-closure-compiler to v20230802 (#51265)
See associated pull request for more information.

PR Close #51265
2023-08-31 16:34:50 +00:00
Luis Castro dc4f77c851 docs(core): clarify InjectionToken usage (#51386)
- Emphasized the importance of using the same InjectionToken instance for both provider and injection call.
- Added examples to illustrate correct usages to prevent NullInjectorError.

PR Close #51386
2023-08-30 15:53:24 +00:00