Commit graph

29329 commits

Author SHA1 Message Date
Joey Perrott
b857aafcb9 refactor: migrate router to prettier formatting (#54318)
Migrate formatting to prettier for router from clang-format

PR Close #54318
2024-02-08 19:17:14 +00:00
Jessica Janiuk
d02fcb1ab4 docs: release notes for the v17.2.0-rc.0 release 2024-02-08 10:43:03 -08:00
Jessica Janiuk
00746d800f release: bump the next branch to v17.3.0-next.0 2024-02-08 10:43:03 -08:00
Jessica Janiuk
c47bf63ccd docs: release notes for the v17.1.3 release 2024-02-08 10:20:12 -08:00
cexbrayat
8dea3b5888 test: tidy up signal signal input/query/model signature tests (#54334)
This updates some tests to use the public imports from `@angular/core` now that they are available,
and cleans up useless imports and inaccurate names.

PR Close #54334
2024-02-08 16:49:15 +00:00
Andrew Scott
898a532aef fix(core): Fix possible infinite loop with markForCheck by partially reverting #54074 (#54329)
In some situations, calling `markForCheck` can result in an infinite
loop in seemingly valid scenarios. When a transplanted view is inserted
before its declaration, it gets refreshed in the retry loop of
`detectChanges`. At this point, the `Dirty` flag has been cleared from
all parents. Calling `markForCheck` marks the insertion tree up to the
root `Dirty`. If the declaration is checked again as a result (i.e.
because it has default change detection) and is reachable because its
parent was marked `Dirty`, this can cause an infinite loop. The
declaration is refreshed again, so the insertion is marked for refresh
(again). We enter an infinite loop if the insertion tree always calls
`markForCheck` for some reason (i.e. `{{createReplayObservable() | async}}`).

While the case above does fall into an infinite loop, it also truly is a
problem in the application. While it's not an infinite synchronous loop,
the declaration and insertion are infinitely dirty and will be refreshed
on every change detection round.

Usually `markForCheck` does not have this problem because the `Dirty`
flag is not cleared until the very end of change detection. However, if
the view did not already have the `Dirty` flag set, it is never cleared
because we never entered view refresh. One solution to this problem
could be to clear the `Dirty` flag even after skipping view refresh but
traversing to children.

PR Close #54329
2024-02-08 16:45:20 +00:00
Kristiyan Kostadinov
adfc3f0f95 refactor(core): temporarily mark subscribe methods as deprecated (#54342)
The `subscribe` methods on `ModelSignal` and `OutputEmitter` were marked as `@internal` which will break when the TCB needs to reference them. These changes make them `@deprecated` temporarily so we can address the properly later.

PR Close #54342
2024-02-08 16:33:41 +00:00
cexbrayat
38b01a3554 fix(compiler-cli): interpolatedSignalNotInvoked diagnostic for model signals (#54338)
The new `model()` signal introduces a `ModelSignal` type that needs to be handled by the interpolatedSignalNotInvoked diagnostic to catch issues like:

```
<div>{{ myModel }}</div>
```

PR Close #54338
2024-02-08 16:28:20 +00:00
ascorbic
03c3b3eb79 feat(common): add Netlify image loader (#54311)
Add an image loader for Netlify Image CDN. It is slightly different in implementation from existing loaders, because it allows absolute URLs

Fixes #54303

PR Close #54311
2024-02-08 16:17:57 +00:00
Kristiyan Kostadinov
9c2bad9e5e refactor(compiler-cli): avoid naming conflict with built-in global variable (#54333)
The import of `module` can conflict with the native global variable called `module` and can break some internal tests. These switch to only importing the function we need.

PR Close #54333
2024-02-08 14:59:54 +00:00
Kristiyan Kostadinov
44f65f2853 refactor(compiler-cli): work around internal test failure (#54327)
Fixes an internal test failure due to `FatalDiagnosticError` extending the native `Error`.

PR Close #54327
2024-02-08 14:59:24 +00:00
Pawel Kozlowski
ca239e8b62 refactor(core): share refresh logic for cd and signal queries (#54322)
Introducing a tiny utility method to remove some code duplication
between the change change detection and signal based queries.

PR Close #54322
2024-02-07 22:22:06 +00:00
Ben Hong
a3e51d99a8 docs: enable version picker (#54161)
PR Close #54161
2024-02-07 22:21:05 +00:00
Paul Gschwendtner
38c0084ed2 test: verify signal-based queries in CLI integration test (#54314)
Adds usages of signal-based queries into the signal integration test to
verify queries can be used in production, and testing environments as
expected (i.e. the transform works as expected).

PR Close #54314
2024-02-07 18:56:04 +00:00
Paul Gschwendtner
a08863e7e0 refactor(compiler-cli): ensure FatalDiagnosticError extends Error (#54309)
This helps with the Angular CLI currently swallowing fatal diagnostic
errors in ways that are extremely difficult to debug due to workers
executing Angular compiler logic.

The worker logic, via piscina, is currently not forwarding such Angular
errors because those don't extend `Error.`

a7042ea27d/src/worker.ts (L175)

Even with access to these errors by manually forwarding errors, via
patching of the Angular CLI, there is no stack trace due to us not using
`Error` as base class for fatal diagnostic errors. This commit improves
this for future debugging and also better reporting of such errors to
our users- if we would accidentally leak one.

PR Close #54309
2024-02-07 16:39:21 +00:00
Paul Gschwendtner
8e237a0161 fix(compiler-cli): properly catch fatal diagnostics in type checking (#54309)
An identical addition to: 760b1f3d0b.

This commit expands the `try/catch`-es:

- to properly NOT throw and just convert the diagnostic.
- to be in place for all top-level instances. Notably, this logic cannot
  reside in the template type checker directly as otherwise we would
  risk multiple duplicate diagnostics.

PR Close #54309
2024-02-07 16:39:20 +00:00
Kristiyan Kostadinov
e921e108e1 refactor(core): correctly distinguish getter functions from writable signals (#54252)
Fixes that `ɵunwrapWritableSignal` inferring getter functions as not matching the interface of `WritableSignal` instead of preserving them.

PR Close #54252
2024-02-07 16:36:15 +00:00
Kristiyan Kostadinov
a4a76c3a38 refactor(core): throw if required model is changed via update too early (#54252)
Adds an assertion that will throw if `ModelSignal.update` is accessed before an initial value is set.

PR Close #54252
2024-02-07 16:36:14 +00:00
Kristiyan Kostadinov
ac9c54487e refactor(core): assert writable signal in two-way property instruction (#54252)
Asserts that the value is a `WritableSignal`, rather than a `Signal`, in the `twoWayProperty` instruction.

PR Close #54252
2024-02-07 16:36:14 +00:00
Kristiyan Kostadinov
243b94c6e1 refactor(compiler-cli): fix regression in two-way bindings to inputs with different getter/setter types (#54252)
In a previous commit the TCB was changed to cast the assignment to an input in order to widen its type to allow `WritableSignal`. This ended up breaking existing inputs whose setter has a wider type than its getter. These changes switch to unwrapping the value on the binding side.

PR Close #54252
2024-02-07 16:36:13 +00:00
Kristiyan Kostadinov
551c5791f8 refactor(core): address PR feedback (#54252)
Addresses the feedback from #54252.

PR Close #54252
2024-02-07 16:36:12 +00:00
Kristiyan Kostadinov
a17f6cb2d0 refactor(compiler-cli): rework TCB for two-way bindings (#54252)
Reworks the TCB for two-way bindings to make them simpler and to avoid regressions for two-way bindings to generic inputs. The new TCB looks as follows:

```
var _t1: Dir;
var _t2 = _t1.input;
(_t1 as typeof _t2 | WritableSignal<typeof _t2>) = expression;
```

PR Close #54252
2024-02-07 16:36:11 +00:00
Kristiyan Kostadinov
372e1ffd25 refactor(compiler-cli): account for model inputs in language service (#54252)
Updates the code that resolves a node from the TCB to an input in order to fix the language service.

PR Close #54252
2024-02-07 16:36:10 +00:00
Kristiyan Kostadinov
702ab28b4c feat(core): add support for model inputs (#54252)
Adds support for model inputs in the framework. `model()` returns a writable signal that implicitly defines a input/output pair that can be used either in two-way bindings to keep two values in sync or by binding individually to the input and output. When the value of the `model` changes, it will emit an event with the current value.

Furthermore, these changes expand two-way bindings to accept `WritableSignal`. This will make it easier to transition existing code to signals in a backwards-compatible way.

Example:

```ts
@Directive({
  selector: 'counter',
  standalone: true,
  host: {
    '(click)': 'increment()',
  }
})
export class Counter {
  value = model(0);

  increment(): void {
    this.value.update(current => current + 1);
  }
}

@Component({
  template: `<counter [(value)]="count"/> The current count is: {{count()}}`,
})
class App {
  count = signal(0);
}
```

PR Close #54252
2024-02-07 16:36:09 +00:00
Kristiyan Kostadinov
d006aa33bf refactor(compiler-cli): add tests for model inputs (#54252)
Adds tests in the compiler to verify the compiled output and template type checking behavior of model inputs.

PR Close #54252
2024-02-07 16:36:08 +00:00
Kristiyan Kostadinov
67b977ea97 refactor(compiler-cli): allow writable signals in two-way bindings (#54252)
Updates the TCB generation logic to allow for `WritableSignal` to be assigned in two-way bindings.

PR Close #54252
2024-02-07 16:36:07 +00:00
Kristiyan Kostadinov
8aac3c45b9 test(core): add runtime acceptance tests for model inputs (#54252)
Sets up the runtime tests for model inputs.

PR Close #54252
2024-02-07 16:36:06 +00:00
Kristiyan Kostadinov
0ea4d7086d refactor(compiler-cli): recognize model fields (#54252)
Adds the logic that recognizes fields initialized to model as an input/output pair.

PR Close #54252
2024-02-07 16:36:05 +00:00
Kristiyan Kostadinov
3faf3e23d5 refactor(core): implement two-way instructions (#54252)
Adds the implementations of the `twoWayProperty` and `twoWayListener` instructions.

PR Close #54252
2024-02-07 16:36:04 +00:00
Kristiyan Kostadinov
06fa029132 refactor(compiler-cli): add jit transform for model inputs (#54252)
Adds a JIT transform that marks `model` fields as `@Input` and `@Output`.

PR Close #54252
2024-02-07 16:36:03 +00:00
Kristiyan Kostadinov
ab0c0cb832 refactor(compiler-cli): add function to identify model fields (#54252)
Adds a function to the compiler to help us identify fields initialized to a `model`.

PR Close #54252
2024-02-07 16:36:02 +00:00
Kristiyan Kostadinov
3e0a20d8fe refactor(core): add model implementation (#54252)
Adds the implementation of the `model` primitive that represents a two-way binding signal-based binding.

PR Close #54252
2024-02-07 16:36:01 +00:00
Paul Gschwendtner
c023e8d58f refactor(core): improve IDE completion of read option for signal queries (#54280)
This commit improves IDE completion of the `read` option for
signal-based queries.

Currently, TS only matches the first overload when starting out with
defining a query. TS doesn't build up the combination of possible
options from the second overload- so in practice users will only see
IDE completions for the `descendants` option.

This is not a problem for view queries as the only option is `read`, so
TS will always match the overload with the `read` option.

```
class X {
  query = contentChild('', {^^ <--
    here we should completion for `read` an `descendants`
}
```

PR Close #54280
2024-02-07 16:35:14 +00:00
cexbrayat
1fb0da2668 build: simplify husky setup (#54315)
husky v9 simplified its setup, see `How to migrate` in https://github.com/typicode/husky/releases/tag/v9.0.1

PR Close #54315
2024-02-07 16:34:13 +00:00
Jessica Janiuk
0dfbde917c Revert "fix(router): Clear internal transition when navigation finalizes (#54261)" (#54317)
This reverts commit 6681292823.

PR Close #54317
2024-02-07 15:46:38 +00:00
Payam Valadkhan
f39cb06418 fix(compiler-cli): show specific error for unresolved @Directive.exportAs in local compilation mode (#54230)
Currently the error is a generic error "exportAs must be a string ...". This commit makes the error more specific to local compilation and adds some action items.

PR Close #54230
2024-02-06 21:33:29 +00:00
Payam Valadkhan
f3851b5945 fix(compiler-cli): show specific error for unresolved @HostBinding's argument in local compilation mode (#54230)
Currently the error is a generic error "selector must be a string ...". This commit makes the error more specific to local compilation and adds some action items.

PR Close #54230
2024-02-06 21:33:29 +00:00
Payam Valadkhan
39ddd884e8 fix(compiler-cli): show specific error for unresolved @HostListener's event name in local compilation mode (#54230)
Currently the error is a generic error "selector must be a string ...". This commit makes the error more specific to local compilation and adds some action items.

PR Close #54230
2024-02-06 21:33:29 +00:00
Payam Valadkhan
5d633240fd fix(compiler-cli): show the correct message for the error LOCAL_COMPILATION_UNRESOLVED_CONST when an unresolved symbol used for @Component.styles (#54230)
Currently the correct error message is shown only if @Component.styles is an array with some unresolved element. This change supports the new case of string type for the @Component.styles field.

PR Close #54230
2024-02-06 21:33:29 +00:00
Payam Valadkhan
6c8b09468a fix(compiler-cli): highlight the unresolved element in the @Component.styles array for the error LOCAL_COMPILATION_UNRESOLVED_CONST (#54230)
Currently the whole array is highlighted.

PR Close #54230
2024-02-06 21:33:29 +00:00
Payam Valadkhan
acc98a17d9 refactor(compiler-cli): add a helper to generate error LOCAL_COMPILATION_UNRESOLVED_CONST in common scenarios (#54230)
A helper `validateLocalCompilationUnresolvedConst` is added to encapsulate a common pattern which leads to the error `LOCAL_COMPILATION_UNRESOLVED_CONST`.

PR Close #54230
2024-02-06 21:33:29 +00:00
Payam Valadkhan
a3de5ba865 refactor(compiler-cli): remove the trailing error message for LOCAL_COMPILATION_UNRESOLVED_CONST (#54230)
The trailing error message comes from tracing the chain of DymaicValue which leads to a mostly useless error that highlights the same symbol as the original message and emits the error message "Unknown reference". This error message is removed in the favour of the original message which suffices.

PR Close #54230
2024-02-06 21:33:29 +00:00
Payam Valadkhan
df74ed94e2 refactor(compiler-cli): upgrade error codes and messages for unresolved symbol errors in local compilation mode (#54230)
A single error code is created to unify the common error pattern in local compilation mode where an imported const cannot be resolved, but needs to be resolved. This mainly happens for Angular decorator fields such as @Component.template.

The error messages are also upgraded to be more centered around this unifying theme.

PR Close #54230
2024-02-06 21:33:29 +00:00
Angular Robot
b5368eb9a6 build: update dependency marked to v12 (#54296)
See associated pull request for more information.

PR Close #54296
2024-02-06 21:13:49 +00:00
Angular Robot
b96c2fec68 build: update dependency jsdom to v24 (#54291)
See associated pull request for more information.

PR Close #54291
2024-02-06 21:10:29 +00:00
Joey Perrott
8efa7cddf7 docs: remove v17 banner from adev (#54287)
PR Close #54287
2024-02-06 21:06:24 +00:00
Alejandro Cuba Ruiz
faf3b45d48 docs: add alejandrocuba.jpg file to images/bios/ (#53842)
PR Close #53842
2024-02-06 20:34:01 +00:00
Alejandro Cuba Ruiz
f189dbe47a docs: add alejandrocuba to GDE resources (#53842)
PR Close #53842
2024-02-06 20:34:01 +00:00
Andrew Scott
6681292823 fix(router): Clear internal transition when navigation finalizes (#54261)
This commit fixes a small memory issue in the router where a destroyed
component instance would be retained.

fixes #54241

PR Close #54261
2024-02-06 20:32:34 +00:00
Angular Robot
c8a973e3b7 build: update dependency husky to v9 (#54289)
See associated pull request for more information.

PR Close #54289
2024-02-06 19:34:46 +00:00