Commit graph

29561 commits

Author SHA1 Message Date
Paul Gschwendtner
1d077fca10 refactor(compiler-cli): expose query function detection logic for JIT 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
2024-02-06 16:04:10 +00:00
Paul Gschwendtner
4851453735 ci: add debug information for failing firebase deploy (#54275)
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
2024-02-06 15:23:13 +00:00
Pawel Kozlowski
99bfbabe50 refactor(core): break circular dependencies in preparation for queries as signals (#54103)
Break circular dependencies by using type imports and code moves.

PR Close #54103
2024-02-06 15:04:36 +00:00
Pawel Kozlowski
84d1fa7c56 refactor(core): pull compileNgModuleFactory out of application_ref (#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
2024-02-06 15:04:36 +00:00
Pawel Kozlowski
3a2ce9e0a2 refactor(core): add error code for required query results (#54103)
This commit introduces a dedicated error code for queries that require
results but none are available.

PR Close #54103
2024-02-06 15:04:36 +00:00
Pawel Kozlowski
20008a6b56 refactor(core): rework runtime implementation to simplify and fix issues (#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
2024-02-06 15:04:36 +00:00
Pawel Kozlowski
1aa63c158b refactor(core): enable content query as signal tests (#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
2024-02-06 15:04:36 +00:00
Pawel Kozlowski
26b11b5b0e test(core): convert query-as-signals test to the compiled ones (#54103)
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
2024-02-06 15:04:36 +00:00
Jessica Janiuk
e46c08170f Revert "fix(compiler-cli): consider the case of duplicate Angular decorators in local compilation diagnostics (#54139)" (#54264)
This reverts commit 4b1d948b36.

PR Close #54264
2024-02-05 18:18:47 +00:00
Jessica Janiuk
bd43aa39a8 Revert "fix(compiler-cli): allow custom/duplicate decorators for @Injectable classes in local compilation mode (#54139)" (#54264)
This reverts commit a592904c69.

PR Close #54264
2024-02-05 18:18:47 +00:00
Jessica Janiuk
a2af706855 Revert "fix(compiler-cli): forbid custom/duplicate decorator when option forbidOrphanComponents is set (#54139)" (#54264)
This reverts commit 96bcf4fb12.

PR Close #54264
2024-02-05 18:18:47 +00:00
Jason Warner
d339941a0d docs: add Jason Warner to GDE resources (#54237)
PR Close #54237
2024-02-05 16:40:57 +00:00
Andrew Kushnir
1090570781 refactor(core): avoid reusing argument name as a local const (#54239)
This refactoring renames a local variable to make sure we do not reuse an argument name, which can lead to confusion and bugs.

PR Close #54239
2024-02-05 15:15:17 +00:00
Andrew Kushnir
90fb623614 refactor(core): create pending task while defer block loading is in progress (#54239)
This commit updates the logic of defer blocks to create an internal pending task to indicate that an application is not yet stable. This change would be helpful for zoneless applications.

PR Close #54239
2024-02-05 15:15:17 +00:00
Matthieu Riegler
f5e5543732 docs: remove an outdated comment. (#54243)
Note: We still expect `ngOnChanges` to not be supported in future signal components.

PR Close #54243
2024-02-05 15:09:40 +00:00
Paul Gschwendtner
8ac4f7d4ef refactor: support multiple acceptance spec files with JIT transforms (#54253)
Updates the acceptance authoring test compiler targets to support
multiple spec files. This will be useful for output, model, inputs
and queries.

PR Close #54253
2024-02-05 15:09:00 +00:00
Paul Gschwendtner
6cb47a7c9d test: verify output() in signals integration test (#54217)
Adds `output()` to the signal inputs integration test to verify
full integration with the Angular CLI. In the future we may
consider renaming the test to something less specific to signal inputs,
but for now this serves the purpose and `output()` is a closely related
part to signal-based inputs.

it doesn't warrant creating another new integration test, as those are
quite expensive to maintain and run.

PR Close #54217
2024-02-05 15:08:35 +00:00
Paul Gschwendtner
efcec0a290 refactor(core): improve type safety for listener instruction (#54217)
The `listener` instruction currently always assumes RxJS subscribables,
and verifies this via `isSubscribable`. The type narrowing is not
ignored and the type remains `any` given the `ngDevMode` check.

This commit improves type safety, and actually switches to a dedicated
interface for "output subscribable" values. This is needed because
`Subscribable` from `RxJS` is typed to expect an observer in object
literal form- which is not correct and doesn't apply to `EventEmitter`
and matches the form of `.subscribe` we are using in the `listener`
instruction.

PR Close #54217
2024-02-05 15:08:35 +00:00
Paul Gschwendtner
02fdd8d6ee test: add tests to verify language-service supports output() function (#54217)
Adds unit tests to verify that the language service supports
the `output()` function with completions, and definition jumping.

PR Close #54217
2024-02-05 15:08:35 +00:00
Paul Gschwendtner
ee635f9aa6 test: add language-service test for type definition of signal inputs (#54217)
Adds an extra unit test for the language-service to verify that type
definitions for signal-based inputs can be resolved.

PR Close #54217
2024-02-05 15:08:35 +00:00
Paul Gschwendtner
b285b1402c refactor(compiler-cli): introduce JIT transform for new output() initializer API (#54217)
Similar to `input()`, initializer-based `output()`'s need to be
transformed in JIT to be annotated with an `@Output()` decorator.

This is necessary so that Angular can statically collect all defined
outputs without instantiating the class (which would not be possible
upon directive definition computation).

This commit introduces a transform next to the input transform that
automatically runs with the Angular CLI and `ng test`.

PR Close #54217
2024-02-05 15:08:35 +00:00
Paul Gschwendtner
55040fb80b test: add type check diagnostic tests for output() API (#54217)
Adds type check diagnostic tests for the `output()` API. This
is necessary because we are maintaining a separate emitter
for `output()` as with the current design (still discussed - but this is
a starting foundation).

Note: `OutputEmitter` currently does not publicly expose `.subscribe`,
while the testing infrastructure exposes it for now. That is because we
are still discussing this before making changes in the TCB to account
for the case where `.subscribe` might be `@internal` ultimately.

PR Close #54217
2024-02-05 15:08:35 +00:00
Paul Gschwendtner
0e9e401ca1 test: generalize type check scenario testing helpers (#54217)
Generalizes the type check table scenario testing infrastructure
so that it can also be used for testing outputs in a table-scheme
without a lot of TS code repetition.

PR Close #54217
2024-02-05 15:08:34 +00:00
Paul Gschwendtner
aa4157cc54 test: add ngtsc compiler test for output() (#54217)
Adds an ngtsc diagnostic and compilation output test for `output()`. The
test will verify certain recognition restrictions and ensures that
diagnostics are raised, in addition to proper full compilation output
being generated (aside from the compliance tests verifying output more
closely).

PR Close #54217
2024-02-05 15:08:34 +00:00
Paul Gschwendtner
65de61ba0d test: add compliance output tests for output() (#54217)
Adds compliance output tests for `output()` to verify that
we are emitting proper full compilation output, as well as proper
partial compilation output that can be linked to match the full output.

PR Close #54217
2024-02-05 15:08:34 +00:00
Paul Gschwendtner
c05e1042b4 refactor(core): introduce output() signature and runtime code (#54217)
This commit introduces the `output()` function and corresponding
runtime code.

In practice, `output()` will defer to `EventEmitter` as outlined in the
RFC, but we are considering limiting the type to a minimal version that
is not coupled with RxJS, less complex, and also has better type safety
around emitting of values.

E.g. currently `EventEmitter.emit` can always be called without
any value, even though the output may be typed to always pass around
values of type `T`. This could cause subtle and confusing bugs.

PR Close #54217
2024-02-05 15:08:34 +00:00
Paul Gschwendtner
f7da77b90d refactor(compiler-cli): detect output() function (#54217)
As we are introducing the new `output()` function as an inituive
alternative to `@Output()` that matches with signal-based inputs,
this commit prepares the compiler to detect such initializer-based
outputs.

PR Close #54217
2024-02-05 15:08:34 +00:00
Payam Valadkhan
96bcf4fb12 fix(compiler-cli): forbid custom/duplicate decorator when option forbidOrphanComponents is set (#54139)
The deps tracker which is responsible to track orphan components does not work for classes mutated by custom decorator. Some work needed to make this happen (tracked in b/320536434). As a result, with option `forbidOrphanComponents` being true the deps tracker will falsely report any component as orphan if it or its NgModule have custom/duplicate decorators. So it is unsafe to use this option in the presence of custom/duplicate decorator and we disable it until it is made compatible. Note that applying custom/duplicate decorators to `@Injectable` classes is ok since these classes never make it into the deps tracker. So we excempt them.

PR Close #54139
2024-02-05 15:07:40 +00:00
Payam Valadkhan
a592904c69 fix(compiler-cli): allow custom/duplicate decorators for @Injectable classes in local compilation mode (#54139)
Custom/duplicate decorators break the deps tracker in local mode. But deps tracker only deals with non-injectable classes. So applying custom/duplicate decorators to `@Injectable` only classes does not disturb deps tracker and local compilation in general. There are also ~ 100 such cases in g3 which cannot be cleaned up.

PR Close #54139
2024-02-05 15:07:40 +00:00
Payam Valadkhan
4b1d948b36 fix(compiler-cli): consider the case of duplicate Angular decorators in local compilation diagnostics (#54139)
For cases like this:

```
@Component({...})
@Component({...})
export class SomeComp {
}
```

The `DecoratorHandler.detect` apparantly matches only one of the `@Component` decorator, leaving the other undetected which will be transformed by TS decorator helper and that breaks local compilation runtimes. But the error message only mentioned "custom" decorator, while in this case it is a "duplicate Angular" decorator. The respective error message is updated thus.

PR Close #54139
2024-02-05 15:07:40 +00:00
László Czöndör
3b1926acdb docs: fix typo in inject-based DI tutorial (#54245)
PR Close #54245
2024-02-05 15:06:11 +00:00
Nigro Simone
350081d445 refactor(docs): fix typo (#54247)
PR Close #54247
2024-02-05 15:05:36 +00:00
Angular Robot
2ab536ee3e docs: update Angular CLI help [main] (#54223)
Updated Angular CLI help contents.

PR Close #54223
2024-02-02 22:01:16 +00:00
Dylan Hunn
f600f0fb27 refactor(compiler): Show an error when a property binding duplicates an i18n attribute (#54063)
Consider the following very quirky Angular template, which has both an i18n attribute binding and a property binding to `in`:
```
<cmp [in]="foo" in="bar" i18n-in />
```

What would you expect the above template to do? `TemplateDefinitionBuilder` will emit the following Ivy instructions:
```
// Element constant attributes
consts: () => {
    __i18nMsg__('bar', [], {}, {})
    return [["in", i18n_0, __AttributeMarker.I18n__, "in"]];
}
// ...
function MyComponent_Template(rf, ctx) {
    if (rf & 1) {
        // Create mode
        i0.ɵɵelement(0, "cmp", 0);
    }
}
```

This makes some sense -- we create a single element, and attach an i18n message to the `in` attribute. But is this actually correct? Notice that the property binding is completely missing!

Indeed, Template Pipeline actually produces this code:
```
// Element constant attributes
consts: () => {
    __i18nMsg__('bar', [], {}, {})
    return [["in", i18n_0, __AttributeMarker.I18n__, "in"]];
}
// ...
function MyComponent_Template(rf, ctx) {
    if (rf & 1) {
        // Create mode
        i0.ɵɵelement(0, "cmp", 0);
    } else if (rf & 2) {
        // Update mode
        i0.ɵɵproperty("in", ctx.foo);
    }
}
```

Aha! There's the property binding! Arguably, this is a bug in `TemplateDefinitionBuilder`, but after some discussion on Slack, we have decided to ban this practice in a future Angular version.

For now, we allow Template Pipeline to have slightly different output, but print an error to warn the user of the issue.

PR Close #54063
2024-02-02 20:52:39 +00:00
Dylan Hunn
8d230e1259 refactor(compiler): Fix a source maps i18n test for Template Pipeline (#54063)
TemplateDefinitionBuilder and Template Pipeline choose different const array orders, which is fine. Update the tests to reflect that.

PR Close #54063
2024-02-02 20:52:39 +00:00
Andrew Scott
74aa8a3888 test(core): ExpressionChanged... error does not happen with signals (#54206)
This test ensures that the `ExpressionChanged...` error does not happen
when signals are updated in a view that is attached to `ApplicationRef`
but was already checked. This was fixed in 432afd1ef4
which actually consequently fixes it for regular `markForCheck` as well.

PR Close #54206
2024-02-02 14:51:46 +00:00
Kristiyan Kostadinov
fc5fe3e8e9 build: rework signals acceptance tests build setup (#54213)
* Renames the `input_signals` directory to `signals` so it can be reused for other tests.
* Reworks the build file to allow multiple test files.

PR Close #54213
2024-02-02 14:51:18 +00:00
mooyil
bdf6927125 docs: remove outdated info about ng serve (#53890)
PR Close #53890
2024-02-01 23:00:18 +00:00
Thabo
32d0742348 docs: fix typo in router.md (#54194)
Correct spelling mistake

PR Close #54194
2024-02-01 22:31:48 +00:00
Andrew Scott
3cf612c857 fix(core): update imports to be compatible with rxjs 6 (#54193)
Peer dependency range allows for rxjs 6. We cannot use features only
available in rxjs 7 unless that changes.

fixes #54192

PR Close #54193
2024-02-01 20:48:19 +00:00
Samuel Marks
908baecf1e [aio/src/styles/custom-themes/{dark,light}-theme.scss] Change theme definitions to resolve warning "Angular Material themes should be created from a map" (#53717)
PR Close #53717
2024-02-01 20:18:42 +00:00
Lars Gyrup Brink Nielsen
0e150c4ae9 docs: correct TypeScript version range for 17.0.x (#53213)
PR Close #53213
2024-02-01 20:07:32 +00:00
Mateusz Daniluk
de777afbc5 refactor: standardize doctype declaration to <!DOCTYPE html> (#51052)
This commit standardizes the doctype declaration across all HTML files in the project to use `<!DOCTYPE html>`

PR Close #51052
2024-02-01 19:29:46 +00:00
Matthieu Riegler
7b2b0f40e2 refactor(core): Guard assertion with ngDevMode (#53764)
`assertDefined` is always guarded elsewhere

PR Close #53764
2024-02-01 19:28:08 +00:00
Matthieu Riegler
bc81440b25 docs(docs-infra): Remove the edit button from AIO (#54204)
As a move to reduce PRs toward AIO we drop the edit button and recommend users to use ADEV instead and make suggestions there.

PR Close #54204
2024-02-01 18:54:55 +00:00
Jessica Janiuk
5d98a023bc ci: Add framework team to adev approvers (#54082)
This adds the entire framework team to the adev approvers list.

PR Close #54082
2024-02-01 17:44:59 +00:00
Angular Robot
36a9bf3d6a build: update actions/checkout action to v4 (#54183)
See associated pull request for more information.

PR Close #54183
2024-02-01 16:02:47 +00:00
Paul Gschwendtner
d74ee6e343 refactor(compiler-cli): group initializer-API based transforms into single transform (#54200)
Instead of maintaining individual transforms for `input`, `output`,
`model` etc. we are grouping them directly and the first one matching,
will execute.

This reduces needed traversal through AST and also makes it a little
more clean to write new initializer API metadata transforms.

Note: The Angular JIT transform is now also moving from `tooling.ts`
directly into `/transformers` for more local placement of transformer
logic.

PR Close #54200
2024-02-01 15:58:50 +00:00
Kristiyan Kostadinov
d89d5230a7 refactor(compiler-cli): allow signal input transform to be reused (#54200)
Splits up the signal input transform so that it can be reused for other signal-based properties.

PR Close #54200
2024-02-01 15:58:50 +00:00
Kristiyan Kostadinov
50b22a4260 refactor(core): move input signals into own directory (#54200)
Moves the signal input code into its own directory to avoid too many files in the `authoring` root once model inputs are introduced.

PR Close #54200
2024-02-01 15:58:50 +00:00