Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a new pull request by comparing changes across two branches #180

Merged
merged 65 commits into from
Feb 8, 2024

Conversation

GulajavaMinistudio
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

pkozlowski-opensource and others added 30 commits February 6, 2024 15:04
This commits converts the hand-written tests into their usual,
compiled form. We can perform this change now since the compiler
bits of the queries-as-signal story landed.

PR Close #54103
This commit adds tests for content queries and fixes the arguments
order in the contentQuerySignal instruction, thus fixing a bug
discovered while adding tests.

PR Close #54103
…ues (#54103)

This commit changes the approach to the reactive node representing query
results: instead of creating a custom node type we can use a computed -
the main change to get there is representing dirty change notification as
a signal (a counter updated every time a query changes its dirty status).

This change is dictated by simplification (we can avoid creation of a custom
signal type) as well as fixes to the multiple issues not covered by the
initial implementation:
- assuring referential stability of results (ex.: the same array instance
  returned from child queries until results change);
- per-view results collection to avoid a situation where accessing query
  results during view creation would return partial / inconsistent results;
- proper refresh of query results for both live and non-connected consumers.

All the above cases are covered by the additional tests in this commit.

PR Close #54103
This commit introduces a dedicated error code for queries that require
results but none are available.

PR Close #54103
…54103)

The compileNgModuleFactory dont need to be in the application_ref file (in fact
the whole logic has little to do with ApplicationRef and it is not even called
from the application_ref). Performing this move to avoid circular dependencies
when the new query as signals authoring functions are exported.

PR Close #54103
…s as signals (#54103)

Break circular dependencies by using type imports and code moves.

PR Close #54103
Adding debug information for failing firebase deploy, hoping
to yield information about the missing resource. The next
multi-site seems to be failing, but is available.

PR Close #54275
… transform (#54257)

This commit exposes the query function detection logic so that it can
be used in the JIT transform later on.

PR Close #54257
…sform 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
…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
…d 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
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
…lly (#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
…54281)

Replace the "event" word with the correct one "property" at the helpful text on event binding section

PR Close #54281
Update to the latest version of angular docs from dev-infra

PR Close #54282
Updated Angular CLI help contents.

PR Close #54276
See associated pull request for more information.

PR Close #53220
See associated pull request for more information.

PR Close #53222
See associated pull request for more information.

PR Close #54202
See associated pull request for more information.

PR Close #54234
See associated pull request for more information.

PR Close #53554
Update typing to show that a number is being used as index rather than any random string

PR Close #54286
See associated pull request for more information.

PR Close #54290
See associated pull request for more information.

PR Close #54288
This commit exposes authoring functions for queries as signals
thus making those generally available.

PR Close #54283
Use signal queries tests with the authoring functions and without
decorators.

PR Close #54283
See associated pull request for more information.

PR Close #54289
)

This commit fixes a small memory issue in the router where a destroyed
component instance would be retained.

fixes #54241

PR Close #54261
pmvald and others added 29 commits February 6, 2024 21:33
…styles array for the error LOCAL_COMPILATION_UNRESOLVED_CONST (#54230)

Currently the whole array is highlighted.

PR Close #54230
…LATION_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
… 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
…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
…rtAs 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
husky v9 simplified its setup, see `How to migrate` in https://github.com/typicode/husky/releases/tag/v9.0.1

PR Close #54315
…eries (#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
Adds the implementation of the `model` primitive that represents a two-way binding signal-based binding.

PR Close #54252
Adds a function to the compiler to help us identify fields initialized to a `model`.

PR Close #54252
Adds a JIT transform that marks `model` fields as `@Input` and `@Output`.

PR Close #54252
Adds the implementations of the `twoWayProperty` and `twoWayListener` instructions.

PR Close #54252
Adds the logic that recognizes fields initialized to model as an input/output pair.

PR Close #54252
Sets up the runtime tests for model inputs.

PR Close #54252
…54252)

Updates the TCB generation logic to allow for `WritableSignal` to be assigned in two-way bindings.

PR Close #54252
Adds tests in the compiler to verify the compiled output and template type checking behavior of model inputs.

PR Close #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
…54252)

Updates the code that resolves a node from the TCB to an input in order to fix the language service.

PR Close #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
Addresses the feedback from #54252.

PR Close #54252
…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
#54252)

Asserts that the value is a `WritableSignal`, rather than a `Signal`, in the `twoWayProperty` instruction.

PR Close #54252
…ly (#54252)

Adds an assertion that will throw if `ModelSignal.update` is accessed before an initial value is set.

PR Close #54252
…signals (#54252)

Fixes that `ɵunwrapWritableSignal` inferring getter functions as not matching the interface of `WritableSignal` instead of preserving them.

PR Close #54252
…54309)

An identical addition to: 760b1f3.

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
…#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.`

https://github.com/piscinajs/piscina/blob/a7042ea27d129f3cad75c422f5aa92f0663854ee/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
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
Introducing a tiny utility method to remove some code duplication
between the change change detection and signal based queries.

PR Close #54322
@GulajavaMinistudio GulajavaMinistudio merged commit c8fb45d into angular-indonesia:main Feb 8, 2024
7 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.