Commit Graph

28249 Commits

Author SHA1 Message Date
Pawel Kozlowski 3bd2fcd044 Revert "feat(core): propertyInterpolationCreate"
This reverts commit 2e3fe0747990647c5cfbba5429e90ed621b18e6e.

Based on the recent design discussion we are going to express property
interpolation as a computed function and reuse the propertyCreate
infrastructure.
2023-10-12 17:27:20 +00:00
Alex Rickabaugh 7feda88abb wip: support local references in signal property bindings
This commit adds support for local refs in signal property bindings, by
generating variables in the creation block. To implement this support:

* a new instruction shallowReference() is introduced, which is not tied to
  the current view context.
* variables are now generated for creation mode as well as update mode
* a new template pipeline pass (`phaseCreationVarColocation`) handles
  ordering of reference variable declaration and assignment in the creation
  block (guaranteeing references are only read after declarations).
2023-10-12 17:27:20 +00:00
Alex Rickabaugh f7265d34ac refactor(compiler): support o.BinaryExpression for assignments
Previously the compiler output AST did not support using
`o.BinaryExpression` for assignments (as TypeScript does). Instead
`o.WriteVarExpr` is defined, which only allows writing to string named
variables.
2023-10-12 17:26:52 +00:00
Paul Gschwendtner 5264c18b53 test: disable input signal initialization test
Still needs to be implemented and discussed.
2023-10-12 17:26:52 +00:00
Paul Gschwendtner 5ab3598746 test: update core API golden to add input API 2023-10-12 17:26:52 +00:00
Paul Gschwendtner f877b544a7 WIP: fix regressions in type checking after signal changes
There was an interesting issue that surfaced in the type checking
tests. Previously an input was type-checked using an expression like:

```ts
myDir.input = myrDir.input2 = userExpr
```

Note how the user expression was only specified once. With signals for
type-checking we cannot do this because both inputs cannot use the same
expression unless we extract it into a separate variable. This is what
this commit implemements.

```ts
const x1 = userExpr;
toWriteableSignal(myDir.input).set(x1);
toWriteableSignal(myDir.input2).set(x2);
```

Note: Even if no input is bound, due to e.g. the `inputs` decorator
field being used and no statically analyzable class member being
discoverable- the user expression should be *evaluated*. This was
something we broke with the initial signal input prototyping.
2023-10-12 17:26:52 +00:00
Pawel Kozlowski f5edc3e9a8 feat(core): propertyInterpolationCreate
Skeleton of the propertyInterpolationCreate instruction.
2023-10-12 17:26:52 +00:00
Paul Gschwendtner 9bf377a424 build: fix lint errors 2023-10-12 17:26:52 +00:00
Pawel Kozlowski 0eced157a9 test: add failing tests for property interpolation
Adding failing tests for the property interpolation so we
keep those instructions on our radar.
2023-10-12 17:26:52 +00:00
Pawel Kozlowski df4196e63f refactor: fix lint issue
Minor refactor to fix the linting job.
2023-10-12 17:26:52 +00:00
Pawel Kozlowski 5dea0312d6 test: binding to a mix of zone and signal inputs
This commit adds a test for a case of a binding targetting
multiple inputs with the same name. Test passes for both
signal based components as well as a mix of zone and signal
based components.
2023-10-12 17:26:52 +00:00
Pawel Kozlowski 7b15e261ad test: enable passing tests after recent code changes
Enabling newly passing tests.
2023-10-12 17:26:51 +00:00
Alex Rickabaugh a59dcb52bd wip: one calculation for many input targets
Wrap bound expressions in `computed` where necessary to ensure all consumers
of a binding see the same value.
2023-10-12 17:26:51 +00:00
Paul Gschwendtner 6cd5dfa966 test: support signal library in compliance test fake_core package
Compliance tests do not depend on the real typings for
`@angular/core`, but rather a fake core package is used.

We want to be able to write compliance tests using signals, so we should
add some rough types to the fake core package. This will also be useful
in `fake_core` for type checking tests.
2023-10-12 17:26:51 +00:00
Paul Gschwendtner 809a96e65d test: generate partial golden for signal compliance test 2023-10-12 17:26:51 +00:00
Paul Gschwendtner 2c6154fe14 test: ensure signal compliance test only runs with template pipeline 2023-10-12 17:26:51 +00:00
Paul Gschwendtner bdbb76f344 refactor: remove debug print for type check block 2023-10-12 17:26:51 +00:00
Paul Gschwendtner 24d689730d test: add test to ensure variable bindings work 2023-10-12 17:26:51 +00:00
Paul Gschwendtner 6310ccc221 WIP: prepare tests for failing scenarios discovered during collab
* Local refs needs more testing
* Basic variable read failed
* We do not have any tests for listeners? there was some restore view
  issue: https://github.com/angular/angular/commit/3acfdf4861d5eeed5b2ad42978547da929cc3567
2023-10-12 17:26:51 +00:00
Pawel Kozlowski faf5b21275 fix(core): properly bind to the same input from multiple views
Before this fix bindings to the same input from multiple LViews didn't
work properly as the binding expression was assigned to LView only on
the first create pass (instead of assigning on each durective usage pass).
2023-10-12 17:26:51 +00:00
Alex Rickabaugh 317ddb0d00 wip: allocate vars for PropertyCreateOp
This commit adds the `ConsumesVarsTrait` to `PropertyCreateOp` which causes
vars to be counted for use in the virtual instructions it might add. This
allows the DOM test to pass.
2023-10-12 17:26:51 +00:00
Pawel Kozlowski b7f33034e8 test: failing test case for non-primitive literals in a template 2023-10-12 17:26:51 +00:00
Pawel Kozlowski a79e202f33 test: add test veryfing bindings to multiple directives 2023-10-12 17:26:51 +00:00
Pawel Kozlowski 92f4d0127f test: add failing test for dom property bindings
The test is skipped as we are not propagating number of vars
based on the bindings found in a template.
2023-10-12 17:26:51 +00:00
Pawel Kozlowski 43cf37aa3e test: re-organize tests 2023-10-12 17:26:51 +00:00
JoostK 41db51bf91 test: add test to bind a signal to a signal input 2023-10-12 17:26:51 +00:00
JoostK 1ae67024cb test: allow signal component test to pass 2023-10-12 17:26:51 +00:00
Alex Rickabaugh b04e75a175 refactor(compiler): only reference a view via a variable if it's not ctx
Previously the template pipeline would prefer to use a local variable
definition in favor of ctx. This commit improves the logic to prefer `ctx`
for the root view even if a variable for the context is available.
2023-10-12 17:26:50 +00:00
Alex Rickabaugh d56cbc2fdf wip: bypass pure functions in input computations 2023-10-12 17:26:50 +00:00
Alex Rickabaugh 49cbecaeab wip: fix signals test
(required and initial values for inputs are mutually incompatible)
2023-10-12 17:26:50 +00:00
Alex Rickabaugh a6702e92aa wip: switch to the real input() implementation 2023-10-12 17:26:50 +00:00
Paul Gschwendtner dadd751a48 refactor: fix lint warnings 2023-10-12 17:26:50 +00:00
Paul Gschwendtner 48054443da refactor: wire up propertyCreate instruction for JIT generation 2023-10-12 17:26:50 +00:00
Paul Gschwendtner 84e0908b29 WIP: setup template pipeline acceptance tests on CI and base setup 2023-10-12 17:26:50 +00:00
Alex Rickabaugh 0f228885bf wip: working signal input and all 3 binding types 2023-10-12 17:26:50 +00:00
Alex Rickabaugh af93b126dd wip: specialize virtual instructions
* splits propertyCreate virtual instructions into DOM vs zone inputs
* integrates with `InputSignal` setting (untested)
* deletes old interfaces/virtual_property impl in favor of Paul's
2023-10-12 17:26:50 +00:00
Alex Rickabaugh f7408579a4 input signals 2023-10-12 17:26:50 +00:00
Paul Gschwendtner c00ab4bcea Fix that signals: true views are never running update mode 2023-10-12 17:26:49 +00:00
Paul Gschwendtner f0a92e2097 WIP: generate propertyCreate instructions in template pipeline 2023-10-12 17:26:49 +00:00
Paul Gschwendtner e35ac097be WIP: create new instruction "propertyCreate" 2023-10-12 17:26:49 +00:00
Paul Gschwendtner 647f57407b WIP: setup http server for test app to test runtime 2023-10-12 17:18:38 +00:00
Paul Gschwendtner 2bb73d1d09 WIP: type checking for signal inputs 2023-10-12 17:18:38 +00:00
Paul Gschwendtner ea48506f67 WIP: Discover input class members in directive shared code. No type-chechking yet. 2023-10-12 17:18:37 +00:00
Paul Gschwendtner d49aec75df WIP: implementation of input function signature 2023-10-12 17:18:37 +00:00
Paul Gschwendtner f050c5b19a WIP: initial input function and test app 2023-10-12 17:18:37 +00:00
Alex Rickabaugh 565032c038 wip: basic proof of concept for virtual instructions 2023-10-12 17:18:37 +00:00
cexbrayat 37c8fd79ac fix(core): handle for alias with as in control flow migration (#52183)
This adds the support of `let index as myIndex` in `*ngFor` for the control flow migration.

Before: `@for (itm of items; track itm)`
After: `@for (itm of items; track itm; let myIndex = $index)`

PR Close #52183
2023-10-12 19:15:19 +02:00
Matthieu Riegler 1c4a3677eb refactor(animations): make AnimationBuilder tree-shakable (#52097)
This commit allows also to use the `AnimationBuilder` when using `provideAnimationsAsync()`

fixes #52096

PR Close #52097
2023-10-12 18:13:22 +02:00
Nicolas Frizzarin f3eebaf76c docs: add Nicolas Frizzarin to GDE resources (#52003)
This PR add Nicolas Frizzarin to the GDE resources

docs: fix typo on description

PR Close #52003
2023-10-12 17:44:41 +02:00
cexbrayat b1cb0b395b fix(common): missing space in ngSwitch equality warning (#52180)
This adds a missing space between the sentences of the `===` vs `==` ngSwitch warning.

PR Close #52180
2023-10-12 15:44:46 +02:00