Commit graph

29561 commits

Author SHA1 Message Date
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
Pawel Kozlowski
43de097704 test(core): enable signal queries tests with authoring (#54283)
Use signal queries tests with the authoring functions and without
decorators.

PR Close #54283
2024-02-06 19:31:58 +00:00
Pawel Kozlowski
e95ef2cbc6 feat(core): expose queries as signals (#54283)
This commit exposes authoring functions for queries as signals
thus making those generally available.

PR Close #54283
2024-02-06 19:31:58 +00:00
Angular Robot
0d4e983c24 build: update dependency @types/jasmine to v5 (#54288)
See associated pull request for more information.

PR Close #54288
2024-02-06 19:30:33 +00:00
Angular Robot
297e73c83b build: update dependency jasmine-core to v5 (#54290)
See associated pull request for more information.

PR Close #54290
2024-02-06 19:30:07 +00:00
Joey Perrott
4d29174585 refactor: address prototype polution concern with better typing (#54286)
Update typing to show that a number is being used as index rather than any random string

PR Close #54286
2024-02-06 18:38:47 +00:00
Angular Robot
4287ca8b50 build: update dependency @octokit/graphql to v7 (#53554)
See associated pull request for more information.

PR Close #53554
2024-02-06 18:24:04 +00:00
Angular Robot
eeafdb6cf3 build: update dependency firebase-tools to v13 (#54234)
See associated pull request for more information.

PR Close #54234
2024-02-06 18:11:41 +00:00
Angular Robot
e9eba6b257 build: update dependency eslint-plugin-jsdoc to v48 (#54202)
See associated pull request for more information.

PR Close #54202
2024-02-06 18:11:12 +00:00
Angular Robot
c512987774 build: update babel dependencies (#53222)
See associated pull request for more information.

PR Close #53222
2024-02-06 18:10:40 +00:00
Angular Robot
e94942255a build: update all non-major dependencies (#53220)
See associated pull request for more information.

PR Close #53220
2024-02-06 18:10:11 +00:00
Angular Robot
2d3fc31c83 docs: update Angular CLI help [main] (#54276)
Updated Angular CLI help contents.

PR Close #54276
2024-02-06 18:09:46 +00:00
Joey Perrott
0763fba97f build: update to latest @angular/docs (#54282)
Update to the latest version of angular docs from dev-infra

PR Close #54282
2024-02-06 17:54:43 +00:00
ilir.beqiri
6ef60c0a1a docs: replace event word with property for binding properties link (#54281)
Replace the "event" word with the correct one "property" at the helpful text on event binding section

PR Close #54281
2024-02-06 17:45:11 +00:00
Paul Gschwendtner
bfbb30618b fix(compiler-cli): do not error due to multiple components named equally (#54273)
Currently, when two components are named `TestComponent`, and both would
use e.g. control flow. Templates would be generated by the compiler and
those would conflict at runtime because the names for the template
functions are not ensured to be unique.

This seems like a more general problem that could be tackled in the
future in the template pipeline by always using the `ConstantPool`, but
for now, we should be good already, given us ensuring the `baseName`'s are
always unique.

PR Close #54273
2024-02-06 17:33:23 +00:00
arturovt
19fae76bad fix(zone.js): patch fs.realpath.native as macrotask (#54208)
This commit updates the implementation of the zone.js `fs` patch to
restore the implementation of `realpath.native` and patches it as a macrotask,
along with other functions of the `fs` package. This is the only nested function
that must be patched.

Closes: #45546

PR Close #54208
2024-02-06 16:04:40 +00:00
Paul Gschwendtner
f8c02b69b9 refactor(compiler-cli): restrict read option values for signal-based queries (#54257)
The `read` option for queries can rely on lexical variables inside the
class. These constructs are fine from a technical perspective in
TypeScript, but in practice, when the component/directive definition is
being created, the read value is extracted into the definition,
**outside** of the class. This breaks `this` references.

To fix this, we are restricting the `read` option to literal values.
Similar to `descendants`. Literal references are in practice constructs
like:

 - `read: bla.X`
 - `read: X`

 where `bla` or `X` is never a `ThisKeywoord`- hence fixing the issue
 and also simplifying the patterns for easier single file compilation.

PR Close #54257
2024-02-06 16:04:10 +00:00
Paul Gschwendtner
902481b6ec refactor(compiler-cli): add JIT transform for signal-based queries (#54257)
This commit adds a JIT transform for signal-based queries, so that
queries are working as expected in JIT environments like `ng test` where
decorator metadata is needed as a prerequisite for the component
definition creation.

This is similar to the JIT transforms for signal inputs etc.

PR Close #54257
2024-02-06 16:04:10 +00:00
Paul Gschwendtner
351426853d refactor(compiler-cli): extract common JIT transform helper into transform API (#54257)
Extracts common JIT transform helper into the transform API, so that
those helpers can be re-used for output, model, queries and inputs.

PR Close #54257
2024-02-06 16:04:10 +00:00