Commit graph

29561 commits

Author SHA1 Message Date
Alex Rickabaugh
ffad7b8ea9 fix(core): untrack various core operations (#54614)
One downside of implicit dependency tracking in `effect()`s is that it's easy
to for downstream code to end up running inside the effect context by accident.
For example, if an effect raises an event (e.g. by `next()`ing a `Subject`), the
subscribers to that `Observable` will run inside the effect's reactive context,
and any signals read within the subscriber will end up as dependencies of the
effect. This is why the `untracked` function is useful, to run certain
operations without incidental signal reads ending up tracked.

However, knowing when this is necessary is non-trivial. For example, injecting
a dependency might cause it to be instantiated, which would run the constructor
in the effect context unless the injection operation is untracked.

Therefore, Angular will automatically drop the reactive context within a number
of framework APIs. This commit addresses these use cases:

* creating and destroying views
* creating and destroying DI injectors
* injecting dependencies
* emitting outputs

Fixes #54548

There are likely other APIs which would benefit from this approach, but this
is a start.

PR Close #54614
2024-02-29 11:38:54 +01:00
Matthieu Riegler
9a8a544e78 docs(docs-infra): remove the override for piscina (#54656)
PR Close #54656
2024-02-29 11:07:07 +01:00
Andrew Scott
c1c7384e02 feat(router): Add reusable types for router guards (#54580)
This refactor makes it easier to update the return types of guards.
Rather than having to track what types guards can return, which may
change with new features over time, `MaybeAsync<GuardResult>` can be
used instead.

PR Close #54580
2024-02-28 18:09:33 +01:00
Kristiyan Kostadinov
fb540e169a feat(core): add migration for invalid two-way bindings (#54630)
As a part of #54154, an old parser behavior came up where two-way bindings were parsed by appending `= $event` to the event side. This was problematic, because it allowed some non-writable expressions to be passed into two-way bindings.

These changes introduce a migration that will change the two-way bindings into two separate input/output bindings that represent the old behavior so that in a future version we can throw a parser error for the invalid expressions.

```ts
// Before
@Component({
  template: `<input [(ngModel)]="a && b"/>`
})
export class MyComp {}

// After
@Component({
  template: `<input [ngModel]="a && b" (ngModelChange)="a && (b = $event)"/>`
})
export class MyComp {}
```

PR Close #54630
2024-02-28 18:06:23 +01:00
Kristiyan Kostadinov
ae7dbe42de fix(compiler-cli): unwrap expressions with type parameters in query read property (#54647)
Fixes that a query like `viewChild('locator', {read: ElementRef<HTMLElement>})` would throw because we didn't account for expressions with type parameters.

I've also included support for parenthesized expressions and `as` expressions since it's pretty easy to support them.

Fixes #54645.

PR Close #54647
2024-02-28 18:05:13 +01:00
Kristiyan Kostadinov
d7c686537a build: update to the TypeScript 5.4 RC (#54643)
Updates the repor to the release candidate of the TypeScript 5.4.

PR Close #54643
2024-02-28 17:43:17 +01:00
Tommy Gaessler
06ffe9a021 docs: updated setting up Zone.js instructions (#52409)
Updated the "Setting up Zone.js" instructions to the latest convention from
how the Angular CLI configures it.
Include adding zone-flats.ts to the tsconfig.app.json file step.
Added src/ to zone-flag.ts in the code example.

PR Close #52409
2024-02-28 17:35:10 +01:00
Kristiyan Kostadinov
c1590e733e docs: fix broken link in AIO (#54649)
Fixes a broken link that is currently breaking the CI.

PR Close #54649
2024-02-28 17:15:06 +01:00
Nikita Barsukov
1519b5bd2f docs: fix broken markdown syntax (#53567)
PR Close #53567
2024-02-28 15:16:14 +01:00
mgechev
2f875d0790 docs: update versioning and deprecation policies (#51423)
Add more details around:
- What we consider a breaking change
- What is a deprecation
- How do we guarantee Angular stays stable
- Update invalid links

PR Close #51423
2024-02-28 14:38:36 +01:00
mgechev
52970e3f23 docs: add updating to v17 guide (#52410)
PR Close #52410
2024-02-28 14:19:45 +01:00
Joey Perrott
2e401c74e7 fix(docs-infra): include CLI reference docs in adev (#54591)
include the reference docs in the adev application

PR Close #54591
2024-02-28 12:48:09 +01:00
Dylan Hunn
e92354570d docs: release notes for the v17.2.3 release 2024-02-27 16:28:23 -08:00
Dylan Hunn
ccda258bc5 release: cut the v17.3.0-next.1 release 2024-02-27 16:12:02 -08:00
Paul Gschwendtner
df0e69b464 build: handle commonjs dependencies when bundling language service (#54429)
Fixes that the language service bundling would throw if a CommonJS dependency is used.

PR Close #54429
2024-02-27 15:24:24 -08:00
Kristiyan Kostadinov
7da459102d refactor(compiler-cli): use semver for version parsing (#54429)
Follow-up to #54423 which uses `semver` to parse the version instead of doing it ourselves.

PR Close #54429
2024-02-27 15:24:23 -08:00
Matthieu Riegler
3d6552cfd8 docs(docs-infra): update angular/build-tooling and angular/docs (#54555)
Fixes #54476, #52603, #52734

PR Close #54555
2024-02-27 15:22:18 -08:00
Sumit Parakh
ff40c9f762 fix(core): fix typo in injectors.svg file (#54596)
this commit fixes the unnecessary single quote in injectors.svg file

Closes #54592

PR Close #54596
2024-02-27 15:21:05 -08:00
Kristiyan Kostadinov
331b16efd2 feat(core): add API to inject attributes on the host node (#54604)
Angular has the `@Attribute` decorator that allows for attributes to be injected from the host node, but we don't have an equivalent for the `inject` function. These changes introduce the new `HostAttributeToken` class that can be used to inject attributes similarly to `@Attribute`. It can be used as follows:

```typescript
import {HostAttributeToken, inject} from '@angular/core';

class MyDir {
  someAttr = inject(new HostAttributeToken('some-attr'));
}
```

The new API works similarly to `@Attribute` with one key exception: it will throw a DI error when the attribute doesn't exist, instead of returning `null` like `@Attribute`. We made this change to align its behavior closer to other injection tokens.

PR Close #54604
2024-02-27 15:18:41 -08:00
Joey Perrott
4066e62db6 ci: use angular/team Github team for minimum review set (#54611)
Use the angular/team Github team to define the list of eligible minimum reviewer set so that it can be reused accross the organization

PR Close #54611
2024-02-27 15:17:07 -08:00
Angular Robot
6470e33a6d build: update io_bazel_rules_sass digest to 888dd9c (#54615)
See associated pull request for more information.

PR Close #54615
2024-02-27 14:06:29 -08:00
Joey Perrott
8f0c27ffc3 refactor(docs-infra): apply prettier formatting to adev (#54625)
Apply prettier formatting to adev code

PR Close #54625
2024-02-27 14:04:49 -08:00
Doug Parker
83d8c68690 release: bump Angular DevTools version to 1.0.11 (#54631)
PR Close #54631
2024-02-27 14:02:15 -08:00
Doug Parker
dd9f9d7d44 Revert "refactor(devtools): implement iframe support for Angular DevTools' browser code (#53934)" (#54629)
This reverts commit dd3dac9cc9.

PR Close #54629
2024-02-27 14:00:13 -08:00
Doug Parker
133319eba0 Revert "refactor(devtools): implement multiframe support in devtools page (#53934)" (#54629)
This reverts commit ebcdc8dc96.

PR Close #54629
2024-02-27 14:00:12 -08:00
Doug Parker
3e0b3a1ec4 refactor: add --spawn_strategy local to --config debug (#54167)
This seems to be necessary to debug Node tests.

PR Close #54167
2024-02-26 18:36:38 -08:00
Andrew Scott
53820dd896 refactor(core): Internal render hooks trigger view refresh before executing user hooks (#54224)
This commit ensures that any internal render hooks that cause views to
become dirty again first refresh those dirty views before running user
render hooks. This ensures that user render hooks have the most complete
render state possible and stops them from needlessly executing multiple
times. This is important to maintain the goal of the public render
hooks, which is to provide the safest place to place code that depends
on DOM state, especially in ways that may force a browser paint.

PR Close #54224
2024-02-26 18:31:13 -08:00
Andrew Scott
46617ce44e refactor(core): Add helper function for queuing state updates (#54224)
This adds a helper function to defer application state updates to the
first possible "safe" moment. If application-wide change detection
(ApplicationRef.tick) is currently executing when this function is used,
the callback will execute as soon as all views attached to the
`ApplicationRef` have been refreshed. Refreshing the application views
will happen again before `checkNoChanges` executes.

When a change detection is _not_ running, this state update will execute
in the microtask queue.

This function is necessary as a replacement for current
`Promise.resolve().then(() => stateUpdate())` to be zoneless compatible
while ensuring those state updates are synchronized to the DOM before
the browser repaint. Without this, updates done in `Promise.resolve(...)` would
queue another round of change detection in zoneless applications, and
this change detection could happen in the next browser frame, and cause
noticeable flicker for the user.

Additionally, this function provides a way to perform state updates that
will run on the server as well as in the browser.

Last, current applications using `ngZone: 'noop'` may not be
calling `ApplicationRef.tick` at all so this function provides a
mechanism to ensure the state update still happens by racing
a microtask with `afterNextRender` (which might never execute).

PR Close #54224
2024-02-26 18:31:13 -08:00
cexbrayat
f578889ca2 fix(compiler-cli): catch function instance properties in interpolated signal diagnostic (#54325)
Currently, the following template compiles without error, even if the signal is not properly called:

```
<div>{{ mySignal.name }}</div>
```

This is because `name` is one of the instance properties of Function (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function#instance_properties).

The interpolated signal diagnostic is now extended to catch such issues.

PR Close #54325
2024-02-26 18:30:05 -08:00
Angular Robot
684290976b build: update scorecard action dependencies (#54407)
See associated pull request for more information.

PR Close #54407
2024-02-26 18:29:36 -08:00
Kristiyan Kostadinov
12dc4d074e fix(compiler-cli): account for as expression in docs extraction (#54414)
Fixes that the extraction for `object-literal-as-enum` didn't account for constants initialized to an `as` expression.

PR Close #54414
2024-02-26 18:29:09 -08:00
Kristiyan Kostadinov
974958913c feat(core): support TypeScript 5.4 (#54414)
Adds support for TypeScript 5.4 to the project.

PR Close #54414
2024-02-26 18:29:09 -08:00
Angular Robot
a2a0067aec build: update all non-major dependencies (#54510)
See associated pull request for more information.

PR Close #54510
2024-02-26 18:28:44 -08:00
cexbrayat
1de9e19250 docs: use components in model inputs guide (#54606)
The code example showcases a `@Directive` with a template instead of a `@Component`.

PR Close #54606
2024-02-26 18:28:10 -08:00
Kristiyan Kostadinov
f5c566c079 fix(compiler-cli): identify aliased initializer functions (#54609)
Fixes that initializer functions weren't being recognized if they are aliased (e.g. `import {model as alias} from '@angular/core';`).

To do this efficiently, I had to introduce the `ImportedSymbolsTracker` which scans the top-level imports of a file and allows them to be checked quickly, without having to go through the type checker. It will be useful in the future when verifying that that initializer APIs aren't used in unexpected places.

I've also introduced tests specifically for the `tryParseInitializerApiMember` function so that we can test it in isolation instead of going through the various functions that call into it.

PR Close #54609
2024-02-26 18:27:15 -08:00
Joey Perrott
54b5a2f130 ci: correct @jeanmeche to @JeanMeche in pullapprove (#54610)
Correct the casing so that it works as expected.

PR Close #54610
2024-02-26 18:25:08 +00:00
Dylan Hunn
69948e1256 refactor(dev-infra): Import angular LS package in g3 (#54608)
Import `angular/packages/language-service` in g3. We will still need to write BUILD files to get it building.

PR Close #54608
2024-02-26 09:04:33 -08:00
Dylan Hunn
d4343b53de Revert "fix(compiler-cli): identify aliased initializer functions (#54480)" (#54595)
This reverts commit f04ecc0cda.

PR Close #54595
2024-02-26 08:36:49 -08:00
Andrew Kushnir
dcb9deb363 fix(core): collect providers from NgModules while rendering @defer block (#52881)
Currently, when a `@defer` block contains standalone components that import NgModules with providers, those providers are not available to components declared within the same NgModule. The problem is that the standalone injector is not created for the host component (that hosts this `@defer` block), since dependencies become defer-loaded, thus no information is available at host component creation time.

This commit updates the logic to collect all providers from all NgModules used as a dependency for standalone components used within a `@defer` block. When an instance of a defer block is created, a new environment injector instance with those providers is created.

Resolves #52876.

PR Close #52881
2024-02-23 12:30:05 -08:00
Pawel Kozlowski
0d95ae51fa refactor(core): use performance API for signals (#54521)
This commit adds a standard performance marker that can be viewed in Chrome dev tools and other tooling.
See more info at https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark

PR Close #54521
2024-02-23 12:18:30 -08:00
Kristiyan Kostadinov
4efcc74dd6 docs: add a guide for model inputs (#54514)
Adds a guide for `model()` inputs for angular.io. Will port this over to angular.dev once it's finalized.

PR Close #54514
2024-02-23 11:47:03 -08:00
Felix Geißler
a3d5f7a2b3 docs: syntax error in signal input transform example (#54567)
PR Close #54567
2024-02-23 11:46:10 -08:00
loka shafeek
835c3a1c27 docs: Update wildcard route component to PageNotFoundComponent (#54570)
This PR enhances the Angular documentation by replacing the placeholder `<component-name>` with the actual `PageNotFoundComponent` in the wildcard route configuration. This update ensures that the documentation accurately reflects the recommended practice for handling page-not-found scenarios. Additionally, it addresses the issue where HTML entities like `&lt;` were being displayed instead of the desired `<` symbol, resulting in clearer and more readable documentation for users.
PR Close #54570
2024-02-23 11:45:38 -08:00
Kristiyan Kostadinov
f04ecc0cda fix(compiler-cli): identify aliased initializer functions (#54480)
Fixes that initializer functions weren't being recognized if they are aliased (e.g. `import {model as alias} from '@angular/core';`).

To do this efficiently, I had to introduce the `ImportedSymbolsTracker` which scans the top-level imports of a file and allows them to be checked quickly, without having to go through the type checker. It will be useful in the future when verifying that that initializer APIs aren't used in unexpected places.

I've also introduced tests specifically for the `tryParseInitializerApiMember` function so that we can test it in isolation instead of going through the various functions that call into it.

PR Close #54480
2024-02-23 11:44:36 -08:00
Lukas Matta
52924c5317 docs: remove mutate function mention (#54569)
PR Close #54569
2024-02-23 11:43:24 -08:00
Matthieu Riegler
35e5ba0ba6 ci: adding Matthieu as approver for ADEV (#54575)
This is to help the team approve changes on the new doc site.

PR Close #54575
2024-02-23 11:42:44 -08:00
Kristiyan Kostadinov
c5a7661319 refactor(compiler-cli): changes to get signal diagnostic working internally (#54585)
The diagnostic for signals that haven't been invoked wasn't working internally, because the path to `@angular/core` is different. These changes resolve the issue and do some general cleanup.

PR Close #54585
2024-02-23 11:42:04 -08:00
Kristiyan Kostadinov
71e0c7df69 fix(migrations): resolve infinite loop for a single line element with a long tag name and angle bracket on a new line (#54588)
Fixes an edge case where a single-line elemnt with a long tag name a closing bracket on a new line was putting the control flow migration into an infinite loop.

Fixes #54587.

PR Close #54588
2024-02-23 11:40:27 -08:00
Dylan Hunn
1a6beae8a2 feat(compiler): Enable template pipeline by default. (#54571)
Template pipeline is now the default template compiler.

A pair of source map tests is failing, related to DI in JIT mode; I will fix and re-enable these during the preview period.

PR Close #54571
2024-02-23 11:15:36 -08:00
Matthieu Riegler
812a9729fa docs(docs-infra): revert font-inlining (#54573)
To fix the CI/Build for ADEV.

PR Close #54573
2024-02-23 18:30:04 +00:00