Commit graph

1244 commits

Author SHA1 Message Date
Miles Malerba
42f203e029 docs: rename @nodoc to @docs-private (#61196)
This aligns with how angular/components marks their hidden APIs.
`@nodoc` has been broken since the switch to adev, this change should
properly hide the APIs again.

PR Close #61196
2025-05-13 17:15:37 -07:00
Paul Gschwendtner
899cb4ab49 refactor: add explicit types for exports relying on inferred call return type (#61316)
As part of the Bazel toolchain migration we noticed that implicit types
generated by the TypeScript compiler sometimes end up referencing types
from other packages (i.e. cross-package imports).

These imports currently work just because the Bazel `ts_library` and
`ng_module` rules automatically inserted a `<amd-module
name="@angular/x" />` into `.d.ts` of packages. This helped TS figure
out how to import a given file. Notably this is custom logic that is not
occuring in vanilla TS or Angular compilations—so we will drop this
magic as part of the toolchain cleanup!

To improve code quality and keep the existing behavior working, we are
doing the following:

- adding a lint rule that reduces the risk of such imports breaking. The
  failure scenario without the rule is that API goldens show unexpected
  diffs, and types might be duplicated in a different package!

- keeping the `<amd-module` headers, but we manually insert them into
  the package entry-points. This should ensure we don't regress
  anywhere; while we also improved general safety around this above.

Long-term, isolated declarations or a lint rule from eslint-typescript
can make this even more robust.

PR Close #61316
2025-05-13 22:46:00 +00:00
arturovt
c6148bd4f0 refactor(service-worker): drop error messages in production (#59702)
This commit provides tree-shakable error messages for the `service-worker` package.

PR Close #59702
2025-04-30 12:41:37 -07:00
arturovt
b55761829e refactor(router): remove Compiler injectee from RouterPreloader (#60945)
This commit removes the `Compiler` injectee from the `RouterPreloader` constructor. It's unused but was still being referenced in the factory definition: `static ɵfac = ɵɵngDeclareFactory(...)`.

PR Close #60945
2025-04-23 15:18:23 +02:00
Matthieu Riegler
880ebf4a71 Revert "refactor(core): use stream in rxResource instead of loader (#59910)" (#60803)
This reverts commit 98a584c1e8.

PR Close #60803
2025-04-09 09:33:27 -07:00
arturovt
6a55970373 refactor(router): replace APP_INITIALIZER (#60719)
The `APP_INITIALIZER` is deprecated. Replaced with `provideAppInitializer`.

PR Close #60719
2025-04-08 16:06:05 -07:00
cexbrayat
56db79a973 refactor(core): use stream in rxResource instead of loader (#59910)
With the changes in #59573, `resource` can now define a `stream` rather than a `loader`.
In the same PR, `rxResource` was updated to leverage this new functionality to handle multiple responses from the underlying observable,
rather than just the first one as it was previously.
This commit renames the `loader` option of `rxResource` into `stream` to be better aligned with its new behavior.

The previous version is temporarily kept and marked as deprecated to help migrating the current usage.

Before
```
usersResource = rxResource({
  request: () => ...,
  loader: ({ request }) => ...
});
```

After
```
usersResource = rxResource({
  request: () => ...,
  stream: ({ request }) => ...
});
```

PR Close #59910
2025-04-08 10:19:15 -07:00
arturovt
635fb00969 refactor(service-worker): pull less RxJS symbols (#60657)
In this commit, we reduce the number of imported RxJS symbols since they are redundant.

- We replace `merge` with a manual observable because `merge` internally pulls in `from()`.
- We remove `defer` and `throwError`, replacing them with `new Observable(s => s.error(..))`.
- We replace `toPromise()` with `new Promise`, as `toPromise()` is deprecated.
- We convert `readyToRegister` to a promise to avoid using RxJS operators like `delay`.

PR Close #60657
2025-04-02 15:00:34 +00:00
Andrew Kushnir
f8ca1d57af build(common): updating golden files for the @angular/common package (#60676)
This commit updates golden files that got changed after swtiching to relative paths. There are no actual change to the APIs, the golden file updates capture the change in imports.

PR Close #60676
2025-04-01 18:16:49 +00:00
Andrew Kushnir
1fa95e5c2e refactor(router): switching to relative imports within the router package (#60674)
This commit updates scripts within `packages/router` to relative imports as a prep work to the upcoming infra updates.

PR Close #60674
2025-04-01 18:16:05 +00:00
Andrew Kushnir
882f96fead refactor(core): produce a message about @defer behavior when HMR is enabled (#60533)
When the HMR is enabled in Angular, all `@defer` block dependencies are loaded
eagerly, instead of waiting for configured trigger conditions. From the DX perspective,
it might be seen as an issue when all dependencies are being loaded eagerly. This commit
adds a logic to produce a message into the console to provide more info for developers.

PR Close #60533
2025-03-28 15:00:32 +00:00
Andrew Scott
958e98e4f7 fix(router): Add missing types to transition (#60307)
The 'types' property was added recently and is available in all browsers that support view transitions

fixes #60285

PR Close #60307
2025-03-28 11:51:07 +00:00
Andrew Scott
f4c4b10ea8 fix(compiler-cli): Produce fatal diagnostic on duplicate decorated properties (#60376)
This prevents the compilation and language service from crashing.

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

PR Close #60376
2025-03-27 20:26:42 +00:00
Andrew Kushnir
96b4f8abde refactor(platform-browser): switching to relative imports within the platform-browser package (#60559)
This commit updates scripts within `packages/platform-browser` to relative imports as a prep work to the upcoming infra updates.

PR Close #60559
2025-03-27 18:31:53 +00:00
Andrew Kushnir
c2ef28062a refactor(animations): convert scripts within packages/animations to relative imports (#60230)
This commit updates scripts within `packages/animations` to relative imports as a prep work to the upcoming infra updates.

PR Close #60230
2025-03-27 18:28:01 +00:00
Andrew Kushnir
1ada286279 build: add build step to the public API extractor script (#60578)
This commit adds a step where we build all found targets in parallel, which speeds up the process of completing public API extractor test/update.

PR Close #60578
2025-03-27 18:13:40 +00:00
Andrew Kushnir
c9562ac2cc refactor(localize): convert scripts within packages/localize to relative imports (#60540)
This commit updates scripts within `packages/localize` to relative imports as a prep work to the upcoming infra updates.

PR Close #60540
2025-03-26 20:40:02 -07:00
Andrew Kushnir
7a65b06665 refactor(core): updates to golden files (#60227) (#60556)
This commit updates golden files to include the changes that appeared after changing imports to relative paths.

PR Close #60227

PR Close #60556
2025-03-26 07:05:23 -07:00
Alan Agius
8e8ccc7927 fix(platform-browser): ensure platformBrowserTesting includes platformBrowser providers (#60480)
Previously, `platformBrowserTesting` did not include any `platformBrowser` providers, causing an inconsistency with `platformBrowserDynamicTesting`.

This update resolves the issue by restructuring platform inheritance to ensure proper provider inclusion:

- `platformCore → platformBrowser → platformBrowserTesting`
- `platformBrowser → platformBrowserDynamic → platformBrowserDynamicTesting`

Now, `platformBrowserTesting` correctly inherits from `platformBrowser`, aligning with the expected behavior.

PR Close #60480
2025-03-20 12:33:13 -07:00
Alan Agius
2466fc9b42 refactor(platform-browser-dynamic): relocate DOMTestComponentRenderer to @angular/platform-browser (#60453)
This commit moves `DOMTestComponentRenderer` to `@angular/platform-browser/testing`, allowing the Angular CLI to eliminate its dependency on `@angular/platform-browser-dynamic`, which would no longer be required for new projects.

PR Close #60453
2025-03-19 19:08:09 +01:00
Pawel Kozlowski
0d2b964d09 refactor(core): add equal option to the signal and computed creation (#60300)
This change moves more logic to the primitives package by pushing
the equal configuration on a reactive node to the signal and
computed creation utilities.

PR Close #60300
2025-03-12 10:38:28 -07:00
Paul Gschwendtner
044dac98c9 feat(bazel): support bundling .d.ts with code splitting (#60321) (#60332)
Instead of relying on Microsoft's API extractor for `d.ts` bundling,
we are switching to Rollup-based `.d.ts` bundling.

This allows us to support code spliting, even for `.d.ts` files,
allowing for relative imports to be used between entry-points, without
ending up duplicating `.d.ts` definitions in two files. This would otherwise cause
problems with assignability of types.

It also nicely integrates into our existing rollup configuration, and
overall simplifies the `ng_package` rule even further!

Notably `tsup` also uses this rollup plugin, and it seems to work well.
Keep in mind that Microsoft's API extractor is pretty hard to integrate,
caused many problems in the past, and isn't capable of code splitting.
This aligns our d.ts bundling with the .mjs bundling (great alignment).

PR Close #60321

PR Close #60332
2025-03-11 15:33:05 -07:00
arturovt
3076254567 refactor(common): drop ngIf assert template error in production (#59705)
This commit removes the `assertTemplate` error message in production.

PR Close #59705
2025-03-05 14:42:19 -08:00
iteriani
8d770eccee refactor(core): Remove the optional flag from Injector and all casts. (#60154)
Note that this does NOT use the retrieve method yet. I believe we need to move the logic for notFoundValue into the inject implementation.

PR Close #60154
2025-03-05 13:44:00 -08:00
Taygan Caldwell
699733fcc3 refactor: add untracked to primitives (#60105)
add untracked to primitives to allow Wiz to use it

PR Close #60105
2025-03-05 12:11:40 -08:00
Matthieu Riegler
26b3a8f206 refactor(http): add context property to httpResource (#60188)
This was an oversight, `context` can be supported out of the box.

PR Close #60188
2025-03-04 19:57:22 +00:00
iteriani
b81ea4f672 refactor(core): Move getCurrentInjector/setCurrentInjector to primitives package. (#60090)
This change casts the injector back and forth since all instances of
injector currently don't implement the `retrieve` method. Note that
the retrieve method is seen as optional, so that Angular can revert back to
inject if necessary.

PR Close #60090
2025-02-28 18:47:09 +00:00
Matthieu Riegler
ee2f07fcff refactor(http): rename map to parse on HttpResourceOptions (#60112)
This reflects more the feature intended for this callback.

PR Close #60112
2025-02-26 11:52:44 -05:00
Kristiyan Kostadinov
7d6636087d fix(common): make types for HttpClient more readable (#59901)
`HttpClient` has a lot of overloads to achieve proper type checking, however each overload is also very long which makes it hard to read on adev. These changes replace the object literal types with `Record` to make them a bit more concise.

PR Close #59901
2025-02-25 13:01:11 -05:00
Miles Malerba
347c3d5761 build: remove circular deps goldens (#60021)
Removes the circular dependencies golden file and cleans up the
associated pullapprove group. All circular dependencies have been
removed and no new ones may be added.

PR Close #60021
2025-02-19 21:01:32 +00:00
Matthieu Riegler
cf36951f83 fix(forms): Fix typing on FormRecord. (#59993)
Priori to this change, `ɵRawValue` of a `FormRecord` returned a `Partial`. This commit fixes it.

fixes #59985

PR Close #59993
2025-02-18 19:28:36 +00:00
Alex Rickabaugh
3e39da593a feat(common): introduce experimental httpResource (#59876)
`httpResource` is a new frontend to the `HttpClient` infrastructure. It
declares a dependency on an HTTP endpoint. The request to be made can be
reactive, updating in response to signals for the URL, method, or otherwise.
The response is returned as an instance of `HttpResource`, a
`WritableResource` with some additional signals which represent parts of the
HTTP response metadata (status, headers, etc).

PR Close #59876
2025-02-14 18:40:37 +00:00
Matt Turco
2588985f43 feat(core): pass signal node to throwInvalidWriteToSignalErrorFn (#59600)
Updates the signature of the `throwInvalidWriteToSignalError` to take the signal node in question and pass it along to the throwInvalidWriteToSignalErrorFn handler function. This allows the handler to e.g. include the signal name in error messaging.

PR Close #59600
2025-02-13 17:56:14 +00:00
Alex Rickabaugh
b592b1b051 fix(core): fix race condition in resource() (#59851)
The refactoring of `resource()` to use `linkedSignal()` introduced the
potential for a race condition where resources would get stuck and not update
in response to a request change. This occurred under a specific condition:

1. The request changes while the resource is still in loading state
2. The resource resolves the previous load before its `effect()` reacts to the
   request change.

In practice, the window for this race is small, because the request change in
(1) will schedule the effect in (2) immediately. However, it's easier to
trigger this sequencing in tests, especially when one resource depends on the
output of another.

To fix the race condition, the resource impl is refactored to track the request
in its state, and ignore resolved values or streams for stale requests. This
refactoring actually makes the resource code simpler and easier to follow as
well.

Fixes #59842

PR Close #59851
2025-02-05 15:01:02 -08:00
Kristiyan Kostadinov
fc5d187da5 fix(platform-server): decouple server from animations module (#59762)
Removes the hard dependency between `platform-server` and `platform-browser/animations` since now the animations module will disable itself automatically.

PR Close #59762
2025-01-29 10:52:18 -08:00
Alex Rickabaugh
6c92d65349 fix(core): add hasValue narrowing to ResourceRef (#59708)
`hasValue` attempts to narrow the type of a resource to exclude `undefined`.
Because of the way signal types merge in TS, this only works if the type
of the resource is the same general type as `hasValue` asserts.

For example, if `res` is `WritableResource<string|undefined>` then
`.hasValue()` correctly asserts that `res` is `WritableResource<string>` and
`.value()` will be narrowed. If `res` is `ResourceRef<string|undefined>`
then that narrowing does _not_ work correctly, since `.hasValue()` will
assert `res` is `WritableResource<string>` and TS will combine that for a
final type of `ResourceRef<string|undefined> & WritableResource<string>`.
The final type of `.value()` then will not narrow.

This commit fixes the above problem by adding a `.hasValue()` override to
`ResourceRef` which asserts the resource is of type `ResourceRef`.

Fixes #59707

PR Close #59708
2025-01-28 09:40:29 +01:00
arturovt
b7dd0483d0 refactor(common): drop error messages in production (#59545)
Switches to using `RuntimeError` and drops error messages in production by replacing it with an error code.

PR Close #59545
2025-01-28 09:39:42 +01:00
Alex Rickabaugh
168516462a feat(core): support default value in resource() (#59655)
Before `resource()` resolves, its value is in an unknown state. By default
it returns `undefined` in these scenarios, so the type of `.value()`
includes `undefined`.

This commit adds a `defaultValue` option to `resource()` and `rxResource()`
which overrides this default. When provided, an unresolved resource will
return this value instead of `undefined`, which simplifies the typing of
`.value()`.

PR Close #59655
2025-01-24 13:39:02 +01:00
Alex Rickabaugh
bc2ad7bfd3 feat(core): support streaming resources (#59573)
This commit adds support for creating `resource()`s with streaming response
data. A streaming resource is defined by a `stream` option instead of a
`loader`, with `stream` being a function returning
`Promise<Signal<{value: T}|{error: unknown}>>`. Once the streaming loader
resolves to a `Signal`, it can continue to update that signal over time, and
the values (or errors) will be delivered to via the resource's state.

`rxResource()` is updated to leverage this new functionality to handle
multiple responses from the underlying Observable.

PR Close #59573
2025-01-21 09:55:32 -08:00
Pawel Kozlowski
04c24472d2 refactor(core): move linkedSignal implementation to primitives (#59501)
This change refactors the Angular-specific linkedSignal implementation
such that its core logic can be shared with other frameworks.

PR Close #59501
2025-01-21 07:58:09 -08:00
arturovt
c51c66ef1e refactor(router): drop forRoot guard in production (#59458)
In this commit, we switch from decorators (which also produce redundant metadata, such as in the `declareFactory`
instruction) to the `inject` function to drop the `ROUTER_FORROOT_GUARD` token in production. This token factory function is only in development mode but is still referenced in the constructor due to the `@Inject(ROUTER_FORROOT_GUARD)` decorator.

PR Close #59458
2025-01-16 13:55:49 -08:00
Alex Rickabaugh
329cf9fbde fix(core): change Resource to use explicit undefined in its typings (#59024)
Originally the `T` in `Resource<T>` represented the resolved type of the
resource, and `undefined` was explicitly added to this type in the `.value`
signal. This turned out to be problematic, as it wasn't possible to write a
type for a resource which didn't return `undefined` values. Such a type is
useful for 2 reasons:

1. to support narrowing of the resource type when `Resource.hasValue()`
   returns `true`.

2. for resources which use a different value instead of `undefined` to
   represent not having a value (for example, array resources which want to
   use `[]` as their default).

Instead, this commit changes `resource()` and `rxResource()` to return an
explicit `ResourceRef<T|undefined>`, and removes the union with `undefined`
from all types related to the resource's value. This way, it's trivially
possible to write `Resource<T>` to represent resources where `.value` only
returns `T`.

`hasValue()` then actually works to perform narrowing, by narrowing the
resource type to `Exclude<T, undefined>`.

PR Close #59024
2025-01-16 09:22:46 -08:00
Andrew Kushnir
d0ad030ec7 Revert "feat(compiler-cli): detect missing structural directive imports (#59443)" (#59544)
This reverts commit ed705a856a.

PR Close #59544
2025-01-15 13:38:37 -08:00
Kevin Brey
ed705a856a feat(compiler-cli): detect missing structural directive imports (#59443)
Adds a new diagnostic that ensures that a standalone component using custom structural directives in a template has the necessary imports for those directives.

Fixes #37322

PR Close #59443
2025-01-15 13:59:37 -05:00
arturovt
3b3040d32a refactor(common): drop error message in production (#59471)
Switches to using `RuntimeError` and drops the error message in production by replacing it with an error code.

PR Close #59471
2025-01-15 12:28:29 -05:00
arturovt
bc77f44802 refactor(common): tree-shake lcpObserver in NgOptimizedImage (#59481)
Prior to this commit, the `this.lcpObserver?.updateImage` expression was still preserved in the production code because it wasn't wrapped with `ngDevMode`. The observer is injected only in development mode. Additionally, we moved the logic from `ngOnDestroy` to avoid having an empty method in production.

PR Close #59481
2025-01-14 14:54:16 -05:00
arturovt
17510becb0 refactor(platform-browser): drop BROWSER_MODULE_PROVIDERS_MARKER in production (#59412)
In this commit, we switch from decorators (which also produce redundant metadata, such as in the
`declareFactory` instruction) to the `inject` function to drop the `BROWSER_MODULE_PROVIDERS_MARKER`
token in production. This token is actually provided only in development mode but is still
referenced in the constructor due to the `@Inject(BROWSER_MODULE_PROVIDERS_MARKER)` decorator.

PR Close #59412
2025-01-10 11:47:32 -05:00
Matthieu Riegler
5c0d68804e fix(core): Ensure that a destroyed effect never run. (#59415)
Prior to this change, a scheduled root effect, even if destroyed instantly, would still run at least once.

This commit fixes this.

fixes #59410

PR Close #59415
2025-01-08 16:40:44 +00:00
Kristiyan Kostadinov
0e23f20c41 fix(platform-browser): styles not replaced during HMR when using animations renderer (#59393)
When we replace a component during HMR, we clear it from the cache of the renderer factory, however when using animations, there's an animation-specific renderer factory that wraps the base DOM one and was preventing the cache from being cleared.

These changes rework the logic that clear the cache to go through a method so we can forward the call to the delegated factory.

PR Close #59393
2025-01-07 15:55:38 +00:00
Samuel Perez
d54deb2ba6 docs: Add NG0750 to errors list (#59265)
This PR adds error NG0750 to Error Encyclopedia.

Update adev/src/content/reference/errors/NG0750.md

Co-authored-by: Andrew Kushnir <43554145+AndrewKushnir@users.noreply.github.com>

Update adev/src/content/reference/errors/NG0750.md

Co-authored-by: Andrew Kushnir <43554145+AndrewKushnir@users.noreply.github.com>

PR Close #59265
2025-01-06 16:13:36 +00:00