Commit graph

3713 commits

Author SHA1 Message Date
Kristiyan Kostadinov
4dda271985 refactor(compiler-cli): split up large file
The `type_check_block.ts` file was getting quite large and difficult to navigate. These changes split up the different pieces of functionality into separate files.

(cherry picked from commit 81bd455de8)
2025-11-14 16:40:14 +00:00
Kristiyan Kostadinov
be371292f2 refactor(compiler-cli): rework type checking for signal forms
Reworks the way we approach type checking of signal forms to be closer to the behavior at runtime. There are a couple of scenarios that we handle:

1. For native controls, we now produce simplified type checking code that looks as follows:

```
var t1 = null! as number | string; // Type depends on the input `type`.
t1 = someField().value();
```

2. For custom controls we generate bindings to the individual inputs, rather than checking conformance against `FormValueControl`/`FormCheckboxControl`. This is closer to the behavior at runtime and it allows us to handle generic directives properly.

(cherry picked from commit f7e58577a4)
2025-11-12 21:13:51 +00:00
Kristiyan Kostadinov
20319fea85 refactor(compiler): remove unused code
The `fullInheritane` flag from the metadata and the `CopyDefinitionFeature` that it controls appear to no longer be used since `fullInheritance` is always false. The feature appears to have been there to support ngcc which was removed some time ago.

(cherry picked from commit 8277906455)
2025-11-11 10:04:32 -08:00
Matthieu Riegler
6213cbf1a8 refactor(core): rename ExperimentalIsolatedShadowDom to IsolatedShadowDom
This API is still experimental

(cherry picked from commit 21ca49cf62)
2025-11-11 08:46:10 -08:00
Kristiyan Kostadinov
c81620f2c1 refactor(compiler-cli): update set of required inputs
Updates the required inputs that can be ignored for form controls.

(cherry picked from commit 877678345a)
2025-11-07 11:57:53 -08:00
Kristiyan Kostadinov
71ab11ccf0 fix(compiler-cli): make field detection logic more robust
Currently the logic for detecting `Field` directives only works if it's imported from `@angular/forms/signals` which doesn't cover our own tests.

These changes make the check more robust.

(cherry picked from commit 0b6b78ca74)
2025-11-07 11:57:53 -08:00
Kristiyan Kostadinov
5b55200edf fix(compiler-cli): allow value to be set on radio fields
Updates the logic that checks for unsupported bindigns to allow `value` to be set on `radio` controls.

(cherry picked from commit a61e01d51f)
2025-11-07 11:57:53 -08:00
Kristiyan Kostadinov
bd322ca410 fix(compiler-cli): do not flag custom control required inputs as missing when field is present
Adds some logic that won't report the `value` or `checked` inputs as missing when the `Field` directive is present since it will bind to the inputs implicitly.

(cherry picked from commit 165634264e)
2025-11-07 11:57:53 -08:00
Kristiyan Kostadinov
01290ab275 fix(compiler-cli): use any when checking field interface conformance
Switches to checking against `FormValueControl<any>` instead of `FormValueControl<unknown>` when checking whether custom controls conform to the interface.

Fixes #64946.

(cherry picked from commit 4d0778529f)
2025-11-07 11:57:53 -08:00
Miles Malerba
a3cb1dfd1a refactor(forms): nicer type errors
By intersecting with `object` instead of `unknown` in the primitive and
`FormControl` cases, we get TypeScript to show nicer type errors that
mention `FieldTree<...>` insetad of `() => FieldState<...>`

(cherry picked from commit 0efb3f6d1f)
2025-11-07 15:45:08 +00:00
Jessica Janiuk
dcfd7fe399 Revert "build: restrain visibility to compiler-cli subpackages (#64732)"
This reverts commit acaa1e6104.
2025-11-06 13:09:27 -08:00
Jessica Janiuk
7c0daeac89 Revert "refactor(compiler-cli): remove deep imports from compiler-cli (#64732)"
This reverts commit af16b48ac7.
2025-11-06 13:09:27 -08:00
Matthieu Riegler
acaa1e6104 build: restrain visibility to compiler-cli subpackages (#64732)
This should solve future deep imports issues.

PR Close #64732
2025-11-06 20:01:27 +00:00
Matthieu Riegler
af16b48ac7 refactor(compiler-cli): remove deep imports from compiler-cli (#64732)
Accessed symbols are grouped into dedicated `private` entries

PR Close #64732
2025-11-06 20:01:27 +00:00
Alan Agius
3bed9f0f16
build: format md files
This commit configures prettier to format markdown files.
2025-11-06 10:07:13 -08:00
Jessica Janiuk
a3c2fe819a Revert "refactor(common): Removes unused imports to clean up dependencies"
This reverts commit 6d3e0f1a51.
2025-11-06 09:05:05 -08:00
SkyZeroZx
6d3e0f1a51 refactor(common): Removes unused imports to clean up dependencies
Eliminates unnecessary imports to reduce clutter and improve maintainability

(cherry picked from commit ca3ef38143)
2025-11-06 16:35:32 +00:00
Miles Malerba
4bdd317596 docs: improve docs generation for namespaces (#64747)
Improves docs epxerience for interfaces / type aliases that are merged
with a namespace.

PR Close #64747
2025-11-05 22:42:59 +00:00
Kristiyan Kostadinov
bdecb0345a test(compiler-cli): set up TCB tests for signal forms
Adds TCB-specific tests for the generated code in signal forms since they tend to be a bit easier to read and follow.

(cherry picked from commit 748caf9a74)
2025-11-05 09:35:53 -08:00
Kristiyan Kostadinov
0e081a6ef9 refactor(compiler-cli): check that custom control conforms to control interfaces
Generates additional type checking code to ensure that custom control conform to either `FormValueControl` or `FormCheckboxControl`.

(cherry picked from commit 3c7751020e)
2025-11-05 09:35:53 -08:00
Kristiyan Kostadinov
93283e076f refactor(compiler-cli): flag unsupported static bindings on field directives
Expands the diagnostic for unuspported bindings on fields to also capture static attributes.

(cherry picked from commit 04ed91071b)
2025-11-05 09:35:52 -08:00
Kristiyan Kostadinov
d1a9258ed2 refactor(compiler-cli): split up form field ops
Splits up the custom form field and native form field into two separate `TcbOp`s with a shared base class.

(cherry picked from commit a5b596b83d)
2025-11-05 09:35:51 -08:00
Kristiyan Kostadinov
c371251e4c fix(compiler-cli): report invalid bindings on form controls
Adds validation that users don't bind to unsupported properties on nodes with the `Field` directive.

(cherry picked from commit f20103a1d7)
2025-11-05 09:35:51 -08:00
Kristiyan Kostadinov
471da8a311 fix(compiler-cli): infer type of custom field controls
Adds the logic to infer the type of a custom field control that's on the same element as the `Field` directive.

(cherry picked from commit 948e2f4f01)
2025-11-05 09:35:51 -08:00
Kristiyan Kostadinov
96cb0cffda fix(compiler-cli): infer types of signal forms set on native inputs
Sets up the logic for inferring the type of the signal form that is set on a native `input`, `textarea` or `select`.

(cherry picked from commit 6b51fc3e9d)
2025-11-05 09:35:50 -08:00
Kristiyan Kostadinov
a021006276 refactor(compiler-cli): allow the forms module to be loaded in tests
Updates the testing utilities to allow for `@angular/forms` to be loaded.

(cherry picked from commit c5ac77cb32)
2025-11-05 09:35:50 -08:00
Leon Senft
507b3466ee perf(forms): implement change detection for field control bindings
For each field state property, check if it has changed since the last
time it was checked before writing it the corresponding form control
property.

The `pattern` and `required` properties of the field state now return a
default value rather than `undefined` if not defined by metadata.

(cherry picked from commit 41be02da2f)
2025-11-04 16:11:33 -08:00
Kristiyan Kostadinov
4c6e29f72f fix(compiler-cli): make required inputs diagnostic less noisy
Currently when a required input is missing, we produce a diagnostic on the entire start tag. This can be really noisy if there are already some attributes on the element.

This change switch to only highlighting the tag name instead.

(cherry picked from commit f233f7420a)
2025-11-03 13:27:54 -08:00
Matthieu Riegler
366392b692 refactor(compiler): desambiguate and export RegularExpressionLiteralExpr
This allows all symbols used by `ExpressionVisitor` to be accessible.

(cherry picked from commit cfba831966)
2025-10-29 13:45:20 -07:00
Miles Malerba
981fabc9b6 feat(docs-infra): add support for namespaces
Adds support for generating docs for namespaces (and merged declarations
of namespace + type)

(cherry picked from commit 662f0e5c00)
2025-10-29 13:22:26 -07:00
Matthieu Riegler
4f21ea72cb refactor(compiler-cli): Remove deep imports of compiler-cli in angular/core
migration schematics will pull from `compiler-cli/private/migrations`
core tests will pull from `compiler-cli/private/testing`

(cherry picked from commit 8e50cdb930)
2025-10-28 15:58:59 +01:00
Jessica Janiuk
e039c6be02 refactor(compiler): Throw an error when old and new animations are used together (#64569)
This adds a new compilation error if someone attempts to put legacy animations and `animate.enter` or `animate.leave` in the same component.

PR Close #64569
2025-10-22 17:14:47 +00:00
Matthieu Riegler
1f389b8b97 fix(compiler-cli): missingStructuralDirective diagnostic produces false negatives (#64579)
Fixes a bug in the missingStructuralDirective diagnostic where structural directives with missing imports were not reported when the element using the structural directive contained other directives

Fixes #64467

co-authored-by: Matt Lewis <npm@mattlewis.me>

PR Close #64579
2025-10-22 16:41:27 +00:00
Matthieu Riegler
54636eacca docs(docs-infra): Extract multiple extends statements for interfaces (#64539)
fixes #64528

PR Close #64539
2025-10-20 21:18:13 +00:00
Jessica Janiuk
75c1849fb3 Revert "fix(compiler-cli): missingStructuralDirective diagnostic produces false negatives (#64470)" (#64541)
This reverts commit c1d870bd38.

PR Close #64541
2025-10-20 14:39:18 +00:00
Matt Lewis
c1d870bd38 fix(compiler-cli): missingStructuralDirective diagnostic produces false negatives (#64470)
Fixes a bug in the missingStructuralDirective diagnostic where structural directives with missing imports were not reported when the element using the structural directive contained other directives

Fixes #64467

PR Close #64470
2025-10-17 19:57:59 +00:00
Jessica Janiuk
dfdcbf7f91 refactor(compiler): add ts-ignore for typescript upgrade (#64468)
This is a quick ts-ignore add to suppress something for later.

PR Close #64468
2025-10-16 17:32:19 +00:00
Andrew Kushnir
a2d8adb395 Revert "refactor(compiler-cli): add a resource debugName transform (#64172)" (#64418)
This reverts commit e941e6b80f.

PR Close #64418
2025-10-14 14:28:16 -07:00
JoostK
49377d274a perf(compiler-cli): fix performance of "interpolated signal not invoked" check (#64410)
This fixes a performance regression from #63754, which is almost a revert of the
prior performance fix in #57291; the latter was provided as quick fix to address
the severe performance overhead this extended diagnostic used to have, with #57337
as follow-up change to address the false negatives that were introduced in #57291.
That follow-up never landed, though, so this commit is re-applying the changes
from #57337 to fix the performance regression.

Fixes #64403

PR Close #64410
2025-10-14 13:47:20 -07:00
Matthieu Riegler
d03970f9d1 refactor(compiler-cli): remove canVisitStructuralAttributes from TemplateCheckWithVisitor (#63809)
This enables checking of expressions of structural directives in template diagnostics.

PR Close #63809
2025-10-14 11:56:14 -07:00
hawkgs
e941e6b80f refactor(compiler-cli): add a resource debugName transform (#64172)
Add a TS transform for `resource` (and `httpResource`) `debugName`. Test the transformations.

PR Close #64172
2025-10-14 09:31:41 -07:00
SkyZeroZx
563dbd998c feat(compiler-cli): Adds diagnostic for misconfigured @defer triggers (#64069)
Warns when @defer blocks define unreachable or redundant triggers, such as multiple main triggers, ineffective prefetches, or timer delays not scheduled before rendering.

PR Close #64069
2025-10-13 11:06:01 -07:00
Matthieu Riegler
62cda789a8 refactor(compiler): Improve pipe in track expression error (#64321)
Throw a parse error for a better context awareness.

fixes #64316

PR Close #64321
2025-10-13 08:59:56 -07:00
Miles Malerba
2fdd4da2a8 refactor(forms): rename the control directive to the field directive (#64300)
Renames the control directive and the input that users set to bind a
field to a UI control.

Previously users would do:

```
<input [control]="someField">
```

Now users will do:

```
<input [filed]="someField">
```

PR Close #64300
2025-10-13 08:59:13 -07:00
Kristiyan Kostadinov
d73d9acbfb build: fix broken test (#64319)
Fixes a test that didn't exist when the recent metadata PR was created.

PR Close #64319
2025-10-09 11:35:29 -07:00
Kristiyan Kostadinov
ab98b2425f fix(compiler-cli): capture metadata for undecorated fields (#63957)
Currently if `TestBed.overrideComponent` is used on a class that uses initializer APIs (e.g. `input()`), the initializer metadata will be wiped out, because `overrideComponent` re-compiles the class with the information set by `setClassMetadata`. `setClassMetadata` only captures decorated members at the moment.

These changes introduce some logic to capture the new initializer-based APIs in `setClassMetadata` as well.

Fixes #57944.

PR Close #63957
2025-10-09 14:02:16 -04:00
Kristiyan Kostadinov
8ceac0b8e9 refactor(compiler-cli): track member metadata using output AST (#63957)
Reworks the logic that tracks the decorator metadata for members to do so using the output AST, rather than wrapping the TypeScript AST. This makes it easier to programmatically generate new members that weren't part of the TypeScript AST before.

PR Close #63957
2025-10-09 14:02:16 -04:00
Kristiyan Kostadinov
ddeef60db2 refactor(compiler): support viewport trigger options in pipeline (#64130)
Updates the template pipeline to support options for the `viewport` triggers.

PR Close #64130
2025-10-09 05:32:20 -07:00
Kristiyan Kostadinov
e2367c8855 refactor(compiler-cli): type check viewport trigger options (#64130)
Updates the template type checker to check the options of the `viewport` trigger against `IntersectionObserver`.

PR Close #64130
2025-10-09 05:32:20 -07:00
Leon Senft
effccffde0 refactor(core): add framework support for binding form controls (#63773)
Move most of the implementation of the `Control` directive into core
framework instructions. This allows field state changes to be propagated
to their corresponding UI controls directly during execution of a
template update block, instead of relying on `effect()`s to synchronize
each change later during the update (and too late in the case of
required inputs).

* Define a private API in `@angular/core` for signal forms to implement:
  * `ɵControl` for the `Control` directive.
  * `ɵFieldState` for the control's associated `FieldState`.
* Emit specialized instructions when compiling a `[control]` binding:
  * `ɵɵcontrolCreate` sets up the `ɵControl` directive if present,
    determines whether it's bound to a native control element or a
    custom control component, and adds the appropriate event listeners
    to notify the `ɵFieldState` of UI changes.
  * `ɵɵcontrol` propagates changes from `ɵFieldState` properties to their
    corresponding UI control properties (in additional to binding the `control`
    property itself).

PR Close #63773
2025-10-04 13:21:55 -07:00