Commit graph

26283 commits

Author SHA1 Message Date
Alex Rickabaugh
bc5ddabdcb feat(core): add Angular Signals to the public API (#49150)
This commit exposes `signal`, `computed`, `effect` and various helpers from
the `@angular/core` entrypoint.

These APIs are marked as `@developerPreview` and are still prototypes in
active development. Their final shapes will be subject to our internal
design reviews as well as one or more community RFCs. We're exporting them
now to allow for experimentation using 16.0.0 next and RC releases.

PR Close #49150
2023-02-22 11:27:21 -08:00
Andrew Scott
5dce2a5a3a feat(common): Provide MockPlatformLocation by default in BrowserTestingModule (#49137)
Tests sometimes do not mock out the `PlatformLocation` and end up
affecting real browser state. This can mean changing the real URL of the
browser during a test, updating the History state object, or any number
of other stateful operations. This can result in a test unintentionally affecting
other tests in the suite because the browser state does not usually get
reset before the next test runs. Providing `MockPlatformLocation` by
default prevents these types of accidental test leakages.

In addition, not providing `MockPlatformLocation` by default led to
developers needing to add `RouterTestingModule` to their test suite to
avoid the problems above. This module has spy `Location` providers which
prevent those issues. This commit now makes `RouterTestingModule`
obsolete. Developers can now just use `RouterModule.forRoot` or
`provideRouter` directly in tests _without_ needing to learn to import
additional test providers or modules.

With this, we should consider deprecating `RouterTestingModule` altogether and
migrating developers to `RouterModule.forRoot` or `provideRouter` instead. There
are some small differences between `SpyLocation` and
`MockPlatformLocation` that might cause tests to fail after the
migration (`MockPlatformLocation` is actually more correct in its
behaviors). If this happens, we can advise developers to also add
`provideLocationMocks()` to their test providers, which would re-provide
the `SpyLocation` like before and should make the tests pass again.

BREAKING CHANGE: `MockPlatformLocation` is now provided by default in tests.
Existing tests may have behaviors which rely on
`BrowserPlatformLocation` instead. For example, direct access to the
`window.history` in either the test or the component rather than going
through the Angular APIs (`Location.getState()`). The quickest fix is to
update the providers in the test suite to override the provider again
`TestBed.configureTestingModule({providers: [{provide: PlatformLocation, useClass: BrowserPlatformLocation}]})`.
The ideal fix would be to update the code to instead be compatible with
`MockPlatformLocation` instead.

PR Close #49137
2023-02-22 11:20:59 -08:00
Cédric Exbrayat
1e32709e0e fix(router): remove RouterEvent from Event union type (#46061)
41e2a68e30 added a `type` property on all router events, and added all type of events to the `Event` union type, but forgot to remove `RouterEvent`.
This removes the benefit of the `type` field, because it is not possible to write:

```
this.router.events.pipe(filter((event: Event): event is NavigationEnd => event.type === EventType.NavigationEnd)).subscribe(/*...*/);
```

as `RouterEvent` does not have a `type` field (hence TS complains).

This commit fixes the issue by removing `RouterEvent` from the union type.

BREAKING CHANGE: The `RouterEvent` type is no longer present in the `Event` union type representing all router event types. If you have code using something like `filter((e: Event): e is RouterEvent => e instanceof RouterEvent)`, you'll need to update it to `filter((e: Event|RouterEvent): e is RouterEvent => e instanceof RouterEvent)`.

PR Close #46061
2023-02-22 11:20:26 -08:00
Alex Rickabaugh
02cd490115 refactor(core): prototype of signals, a reactive primitive for Angular (#49091)
This commit checks in (but does not export) a prototype implementation of
Angular Signals, along with its unit test suite and a README explaining the
algorithms used.

Signals are not a new concept in the framework space, but there are many
different flavors of implementations. These differ radically both in terms
of public API as well as behavioral details (such as eager vs lazy
computation, batching behavior, equality, cleanup, nesting, etc).

This commit comprises a bespoke implementation that we've designed to best
meet Angular's needs, especially when it comes to compatibility and
flexibility of use within existing applications.

Many of the API features of this implementation of signals, as well as the
larger direction of reactivity in Angular, will be discussed in future RFCs.

Co-Authored-By: Pawel Kozlowski <pkozlowski.opensource@gmail.com>

PR Close #49091
2023-02-21 14:13:08 -08:00
Angular Robot
b0c995a223 build: update actions/cache digest to 69d9d44 (#49148)
See associated pull request for more information.

PR Close #49148
2023-02-21 13:36:40 -08:00
Kristiyan Kostadinov
2268278ce9 fix(migrations): don't copy animations modules into the imports of test components (#49147)
Since we have less information about how to copy test components, we copy all the `imports` from the `configureTestingModule` call into the component's `imports`. It fixes some tests, but it can cause issues with animations modules, because they throw errors if they're imported multiple times.

These changes add an exception for animations modules imported in testing modules.

PR Close #49147
2023-02-21 13:35:43 -08:00
Angular Robot
6966a043c0 build: update eslint dependencies to v5.53.0 (#49146)
See associated pull request for more information.

PR Close #49146
2023-02-21 13:24:15 -08:00
Walid Bouguima
62350ca41b docs(router): canMatch route guard method signature update (#49140)
Very cosmetic, but it might be necessary : 

I updated the ```canAccess``` method second signature name and type in the provided sample. As it stands, it triggers `TS(2345):  Argument of type 'Route' is not assignable to parameter of type 'string'`.
PR Close #49140
2023-02-21 13:23:07 -08:00
Kristiyan Kostadinov
36b9ff7ff9 fix(migrations): return correct alias when conflicting import exists (#49139)
Fixes that the `ImportManager` was returning the `propertyName` instead of the `name` when there's an import with a conflicting identifier.

PR Close #49139
2023-02-21 13:17:21 -08:00
Kristiyan Kostadinov
913605085a build: update AIO to TypeScript 4.9 (#49135)
Updates AIO to the latest stable version of TypeScript as a prerequisite to drop support for 4.8.

PR Close #49135
2023-02-21 13:16:35 -08:00
Kalbarczyk
637102d992 docs: add NG Poland 2023 and JS Poland 2023 to events (#48972)
docs: add NG Poland 2023 and JS Poland 2023 to events
PR Close #48972
2023-02-21 13:16:05 -08:00
Andrew Kushnir
83a6e203e3 refactor(compiler): drop obsolete NgFactory and NgSummary config options (#48268)
The options to generate NgFactory and NgSummary files were added to Ivy for backwards compatibility with ViewEngine. Since ViewEngine was deprecated and removed, the NgFactory and NgSummary files are no longer used as well.

This commit drops obsolete options to generate NgFactory and NgSummary files. Also, the logic that generates those files is also removed.

PR Close #48268
2023-02-21 13:03:59 -08:00
Paul Gschwendtner
f9b6a3fecc ci: attempt to fix node windows job flakiness (#49142)
Ocasionally Node is randomly not installed in the Windows job. We've
been trying to debug this for a while. With the additonal debug
information it looks like in some situations the NodeJS folder from
NVM is not even present.

One idea is to use `nvm on` to ensure NVM is actually enabled. It's
unclear why it would be `off` at VM start, but it's worth giving a try.

Trying `nvm off` via SSH yields similar issues as we saw in the flaky
workflows:
https://app.circleci.com/pipelines/github/angular/angular/56160/workflows/2f1b80b3-29c7-4274-804e-cb994c20aff0/jobs/1287228

PR Close #49142
2023-02-20 15:16:53 +00:00
Paul Gschwendtner
c8be8fa79f ci: fix rbe initialization failing in windows job (#49142)
The RBE init script from dev-infra is using ES2020 but
the image NodeJS version does not support e.g. nullish coalescing.

PR Close #49142
2023-02-20 15:16:53 +00:00
Joey Perrott
8ba8e0dcff build: update to latest remote build execution setup (#49133)
Update to the latest RBE setup after key rotation.

PR Close #49133
2023-02-18 02:42:27 +00:00
Andrew Kushnir
c872426fa9 ci: update AIO payload size tracking (#49130)
This commit updates a golden file to decrease an expected payload size.

PR Close #49130
2023-02-17 11:55:01 -08:00
cexbrayat
8fb63dff94 refactor(http): simplify HttpClientModule XSRF configuration (#48957)
The current configuration of `HttpClientModule` explicitely enables the XSRF configuration,
but this XSRF configuration is the one used by default by `provideHttpClient`.

See https://github.com/angular/angular/blob/main/packages/common/http/src/provider.ts#L50-L98

PR Close #48957
2023-02-17 11:17:53 -08:00
Alan Agius
9b9c818f99 perf(core): change RendererType2.styles to accept a only a flat array (#49072)
While unlikely, prior to this change it was possible to provide a nested array of styles to the render. This required the framework to handle this by doing a flatten operation. This change also renames the `flattenStyles` method as it no longer flattens the styles.

BREAKING CHANGE: `RendererType2.styles` no longer accepts a nested arrays.

Closes #48317

PR Close #49072
2023-02-17 11:11:48 -08:00
Angular Robot
2535883c42 build: update io_bazel_rules_sass digest to a2efcd6 (#49122)
See associated pull request for more information.

PR Close #49122
2023-02-17 11:11:00 -08:00
Angular Robot
0b3eacbbcc docs: update Angular CLI help [main] (#49119)
Updated Angular CLI help contents.

PR Close #49119
2023-02-17 11:10:30 -08:00
Alan Agius
2d51b5f644 Revert "fix(platform-server): insert transfer state script before other script tags (#48868)" (#49112)
This reverts commit 2fc5b70fce as this change is no longer needed since `type=module` script are deferred by default. Which causes the transfer data to be queried after the browser has finished parsing the DOM.

PR Close #49112
2023-02-17 11:09:21 -08:00
Matthieu Riegler
f12ba1c6dd refactor: remove unnecessary file (#49042)
view had a single export from a file located in the same package, no need to keep it.

PR Close #49042
2023-02-17 11:08:33 -08:00
Alan Agius
09e06fbfed test: remove cli-hello-world-ivy-compat integration test (#49111)
This now is the same as `cli-hello-world` since this test does not use View Engine

PR Close #49111
2023-02-17 11:07:28 -08:00
Virginia Dooley
ca53adeceb docs: New doc HTTP client - Pass metadata to interceptors. (#48918)
PR Close #48918
2023-02-17 11:06:57 -08:00
Virginia Dooley
68f67d6835 docs: New doc HTTP client - Test requests (#48917)
PR Close #48917
2023-02-17 11:06:03 -08:00
Virginia Dooley
e6a622df38 docs: New doc HTTP client - Security: Cross-Site Request Forgery (XSRF) protection (#48916)
PR Close #48916
2023-02-17 11:05:26 -08:00
Virginia Dooley
db4e903e39 docs: New doc extract from original HTTP doc to be retired. (#48913)
PR Close #48913
2023-02-17 11:04:50 -08:00
Virginia Dooley
18c7fac63b docs: new doc extract from original HTTP doc to be retired. (#48911)
PR Close #48911
2023-02-17 11:04:21 -08:00
Virginia Dooley
e58f814c20 docs: new doc extract from original HTTP doc which is to be retired. (#48905)
PR Close #48905
2023-02-17 11:03:48 -08:00
Virginia Dooley
4adc790a81 docs: New document extracted from the original Communicating with backend services using HTTP document, which is to be retired. (#47965)
PR Close #47965
2023-02-17 11:03:05 -08:00
Andrew Scott
1f055b90b6 fix(router): Ensure anchor scrolling happens on ignored same URL navigations (#48025)
The Router scroller only listens for NavigationEnd events. However, the
default behavior of the Router is to ignore navigations to the same URL.
This breaks the anchor scrolling when clicking on an anchor whose
fragment is already in the URL.

fixes #29099

BREAKING CHANGE: The `Scroll` event's `routerEvent` property may also be
a `NavigationSkipped` event. Previously, it was only a `NavigationEnd`
event.

PR Close #48025
2023-02-17 11:00:27 -08:00
Alan Agius
48aa96ea13 refactor: remove Angular Compatibility Compiler (ngcc) (#49101)
This commit removes the NGCC code and all the related infra setup required to support it.

BREAKING CHANGE: Angular Compatibility Compiler (ngcc) has been removed and as a result Angular View Engine libraries will no longer work

PR Close #49101
2023-02-16 16:01:17 -08:00
Andrew Kushnir
9105c41f44 fix(platform-server): avoid duplicate TransferState info after renderApplication call (#49094)
This commit updates the `renderApplication` function to avoid duplicate serialization of the data from the `TransferState` class. The `renderApplication` function imports providers from the `ServerModule`, which already include the `TransferState` serialization providers, but the same providers were also included inside the `renderApplication` as well, which led to the duplication.

PR Close #49094
2023-02-16 16:00:29 -08:00
Matthieu Riegler
07db67b4d7 refactor: restore tree shaking for a warning message (#49064)
`getInheritedInjectableDef` logs a depreciation warning that can be tree shaked in prod. Let's do it.

PR Close #49064
2023-02-16 15:55:44 -08:00
Matthieu Riegler
dcd82ba719 docs: fixing typo in angular compiler options (#49085)
The strictness flags that this "option" instead of "open".

Fixes #49078

PR Close #49085
2023-02-16 15:54:14 -08:00
Andrew Scott
bf7de25e8a refactor(router): Remove warning for an invalid ActivatedRoute (#49117)
This warning was put in place to surface an error when developers use an ActivatedRoute
with an invalid structure in tests. However, there isn't a clear path to fixing it and
the tests continue to pass (ideally - that's what the recovery code is there for).
Rather than surfacing an error that developers would be confused by and likely ignore,
it would be better to not warn at all unless there is a clearer action to take to
resolve the issue.

resolves #49116

PR Close #49117
2023-02-16 15:53:29 -08:00
John Manners
320f36f217 docs: fix typo in toh-pt5.md (#49108)
Line 254 - change 'liberate' to 'liberates'.
PR Close #49108
2023-02-16 15:52:33 -08:00
John Manners
d2a7245ea7 docs: improve sentence in toh-pt5.md (#49109)
Line 302 - improve clarity.
PR Close #49109
2023-02-16 15:51:27 -08:00
Ikko Eltociear Ashimine
918e6f09b9 docs: fix typo in router-tutorial-toh.md (#49095)
non-existant -> non-existent
PR Close #49095
2023-02-16 15:50:55 -08:00
Ilyass
6b8636fff8 docs(core): typo adding missing comma (#49088)
PR Close #49088
2023-02-16 15:49:09 -08:00
Kristiyan Kostadinov
06605cc760 docs: add guide for standalone migration (#49044)
Adds a guide describing how to use the standalone migration schematic. The new guide is grouped together with the existing standalone guide.

PR Close #49044
2023-02-16 15:33:18 -08:00
mgechev
0c7b9aab34 docs: close the developer survey (#49092)
PR Close #49092
2023-02-16 15:32:45 -08:00
Paul Gschwendtner
2a4d9879db build: avoid unnecessary re-evaluation of starlark code (#49106)
The experimental allow tags propagation flag is a `BuildLanguage` option
and causes all Starlark code to be re-invoked. This causes a slow-down
when switching between bazel query/ bazel build because the option is not set for `bazel query`.

We fix it by applying the option to all commands, using `common`.

PR Close #49106
2023-02-16 15:31:55 -08:00
Alan Agius
02d5e8d79d fix(platform-browser): remove styles from DOM of destroyed components (#48298)
Currently style of components using `encapsulation`, `None` or `Emulated` will not be removed from the DOM once the component get destroyed.

This change addresses this by keeping track of the number of times a component is rendered, when the component is destroyed the counter is decreased and once this reaches zero the style element is removed from the DOM.

Currently, this new behaviour is on opt-in bases, but it will be changed in the next major version.

To opt-in, set the `REMOVE_STYLES_ON_COMPONENT_DESTROY` DI token to `true`.

Example
```ts
@NgModule({
 declarations: [
   AppComponent,
 ],
 imports: [
   BrowserModule
 ],
 providers: [
   { provide: REMOVE_STYLES_ON_COMPONENT_DESTROY, useValue: true }
 ],
 bootstrap: [AppComponent]
})
export class AppModule { }
```

Closes #16670

PR Close #48298
2023-02-16 15:31:24 -08:00
Kristiyan Kostadinov
f3f139942c refactor(compiler): remove remaining usage of getMutableClone (#49070)
Uses an alternate approach of preserving default imports that doesn't involve the `getMutableClone` function that is being removed in TypeScript 5.0.

The alternate approach was already used in the downlevel transform and it works by patching the EmitResolver of the current transformation context to tell TypeScript to preserve the import.

PR Close #49070
2023-02-16 15:30:52 -08:00
Joey Perrott
3a6aebf349 fix(bazel): stop publishing @angular/bazel package to npm (#49093)
We are no longer publishing the @angular/bazel package in prepeartion for its removal from the angular/angular repo.
The piece that we still rely on for our own infrastructure will be moved to angular/dev-infra.

PR Close #49093
2023-02-16 11:04:00 -08:00
Joey Perrott
6977403a9b release: bump version to 16.0.0-next.0 (#49084)
PR Close #49084
2023-02-16 10:51:33 -08:00
Pawel Kozlowski
be21eaa618 docs: release notes for the v15.2.0-rc.0 release 2023-02-15 18:48:45 +01:00
Pawel Kozlowski
c3609eca9d release: bump the next branch to v15.3.0-next.0 2023-02-15 18:48:45 +01:00
Pawel Kozlowski
44f13e2f2b docs: release notes for the v15.1.5 release 2023-02-15 18:38:17 +01:00