Commit graph

2209 commits

Author SHA1 Message Date
Kristiyan Kostadinov
cd405685af fix(compiler-cli): fix up spelling of diagnostic
Fixes the spelling for the `component is missing a template` diagnostic and expands it a bit.

(cherry picked from commit 3a26244d61)
2026-01-02 08:27:30 +01:00
Kristiyan Kostadinov
523dbaf1c3 fix(compiler): stop ThisReceiver inheritance from ImplicitReceiver
Back in #39323, I added a new `ThisReceiver` node to represent accesses done through `this` and I ended up making it inherit from `ImplicitReceiver`. The logic was that in most cases accessing through `this` was the same as the implicit access.

Over the years this has proven to not be a great idea, because no other AST nodes do this and one has to keep it in mind whenever dealing with `ImplicitReceiver`.

These changes remove the inheritance and update all of the usage sites accordingly.

(cherry picked from commit fa7cb4b87a)
2026-01-02 08:21:53 +01:00
JoostK
778460fcca fix(compiler-cli): support qualified names in typeof type references
This commit expands the static interpreter to now understand qualified names in `typeof`
type queries.

Fixes #65686

(cherry picked from commit f12e160bc1)
2026-01-02 08:21:12 +01:00
JoostK
4d9c4567ed fix(compiler-cli): ensure component import diagnostics are reported within the imports expression
PR #60455 improved error reporting for `@Component.imports` by scoping the diagnostic to an individual
element within the `imports` array, but this may introduce hard to track diagnostics when it ends
up being reported (far) away from the component itself.

This can be even more problematic when the diagnostic would end up being reported in a declaration file,
as happened in issue #65686; the declaration files of an imported library contained syntax that the
static interpreter did not support, hence the `@Component.imports` was rejected with a diagnostic reported
in the library's declaration file. This diagnostic isn't guaranteed to be reported (e.g. the CLI only
gathers Angular-specific diagnostics for Angular-compiled files, which excludes declaration files).

This commit changes the diagnostic location to ensure it is being reported within the `@Component.imports`
expression, in most cases retaining the desirable effect of #60455 while avoiding out-of-band diagnostics.

(cherry picked from commit 106ba63650)
2026-01-02 08:21:12 +01:00
Leon Senft
ec110f170b fix(forms): allow custom controls to require pending input
* Allow custom controls to make `pending` a required input
* Refactor test for `pending` input to be consistent with other control
  properties
* Test that `pending` inputs are reset when the field binding changes

(cherry picked from commit 1a4c3eb1d0)
2026-01-02 08:09:39 +01:00
Leon Senft
561772b152 fix(forms): allow custom controls to require dirty input
* Allow custom controls to make `dirty` a required input
* Refactor test for `dirty` input to be consistent with other control
  properties
* Test that `dirty` inputs are reset when the field binding changes

(cherry picked from commit 89c37f1f7f)
2026-01-02 08:09:39 +01:00
Leon Senft
f0fb1d8581 fix(forms): allow custom controls to require hidden input
* Allow custom controls to make `hidden` a required input
* Refactor test for `hidden` input to be consistent with other control
  properties
* Test that `hidden` inputs are reset when the field binding changes

(cherry picked from commit 82edf18427)
2026-01-02 08:09:38 +01:00
Leon Senft
9748b0d5da fix(forms): support custom controls with non signal-based models
* Recognize directives with non signal-based models as valid custom controls
* Relax type checker to allow non signal-based models

The `FormValueControl` and `FormCheckboxControl` interfaces still
require a `model()`-input, however, a custom control need not implement
either interface to be bound by the `Field` directive.

All of the following examples can be used to define a custom control:

```ts
// Preferred: model()
class MyFormControl implements FormValueControl<string> {
  readonly value: model.required<string>();
}

// Supported: input() + output()
class MyFormControl {
  readonly value: input.required<string>();
  readonly valueChange: output<string>();
}

// Supported: @Input() + @Output()
class MyFormControl {
  @Input({required: true}) value!: string;
  @Output() valueChange: new EventEmitter<string>();
}
```

The latter two may still choose to implement `FormUiControl` for other
properties, but again it is not required.

Fix #65478

(cherry picked from commit cb09fb8308)
2026-01-02 08:09:07 +01:00
Matthieu Riegler
feed89e83c ci: reformat files
This is after we've slightly changed a rule in #66056

(cherry picked from commit 6270bba056)
2025-12-16 14:44:25 -08:00
Kristiyan Kostadinov
65297c6201 fix(compiler-cli): expand type for native controls with a dynamic type
We recently allowed users to have a dynamic input `type` with signal forms, but the logic that infers the value type falls back to `string` even though in theory it can be any of the other types.

These changes expand the inferred type to `string | number | boolean | Date | null` if we detect a dynamic `type` binding.

(cherry picked from commit 8a3f3a91cf)
2025-12-09 13:01:35 -08:00
Matthieu Riegler
ffad78360f refactor(core): add dedicated deprecated signatures for providedIn: any / NgModule.
Those were deprecated by #47616 back in v15.

fixes #65923

(cherry picked from commit 8199945637)
2025-12-09 10:38:14 -08:00
Kristiyan Kostadinov
1f1856e897 fix(compiler-cli): check that field radio button values are strings
Adds some type checking code which verifies that the bound `value` on a `Field` radio button is a string.

Fixes #65726.

(cherry picked from commit 6773d3b97d)
2025-12-03 12:19:01 +01:00
Kristiyan Kostadinov
5a80a48e96 fix(compiler-cli): avoid allocating an object for signals in production mode
Currently when the signal debug name transform sees something like `const foo = signal(0);`, it transforms the signal into `signal(0, {...(ngDevMode ? { debugName: 'foo' } : {})})`. After minification this becomes `signal(0, {})` which will allocate memory for the empty object literal.

These changes rework the logic to produce `signal(0, ...(ngDevMode ? [{ debugName: 'foo' }] : []))` which will be fully tree shaken away to `signal(0)`.

(cherry picked from commit e30e61b789)
2025-12-02 15:06:55 +01:00
SkyZeroZx
b7ccb308b8 docs(docs-infra): Improves symbol linking for Angular Aria selectors
Improves the symbol linking logic to handle Angular component selectors (e.g., ngCombobox). It attempts to convert Angular selector patterns to their corresponding class names, improving navigation to Angular API documentation.

(cherry picked from commit 2d854e01bc)
2025-12-01 18:47:23 +01:00
AntonChesnokov
8d3a89a477 fix(compiler-cli): escape angular control flow in jsdoc
Escape @-prefixed template control flow constructs during doc extraction so JSDoc parsing keeps description text intact. Add regression coverage for @for snippets.

(cherry picked from commit 5bfa027d41)
2025-11-25 11:33:29 -05:00
Leon Senft
8acf5d2756 fix(forms): allow dynamic type bindings on signal form controls
The type checker will no longer prohibit binding the Signal Forms `[field]`
directive to an input with a dynamic `[attr.type]` or `[type]` binding.

(cherry picked from commit 3a1eb07c46)
2025-11-25 09:16:01 -05:00
Kristiyan Kostadinov
39c577bc36 fix(compiler-cli): do not type check native controls with ControlValueAccessor
Currently when we detect a `field` binding on a native element, we treat it as a built-in native control. This might not be the case if it's a pre-existing `ControlValueAccessor` relying on the CVA interop.

These changes try to detect any CVA-like directive on the element and disable the additional type checking if there are any.

Fixes #65468.

(cherry picked from commit 6b8720de91)
2025-11-24 13:08:46 -05:00
Kristiyan Kostadinov
f0b34854cc refactor(compiler-cli): track public methods during analysis
Updates the directive analysis to track the public methods of the class.

(cherry picked from commit 5cfdd7897b)
2025-11-24 13:08:46 -05:00
hawkgs
98520333bd 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-11-24 11:30:13 -05:00
Syam Gadde
bc34083d34 fix(compiler-cli): ignore non-existent files
Ignore files that fail fs.exists() rather than throw ENOENT.  Some applications deliberately create "broken" symbolic links that are not relevant to compilation (e.g. emacs lock files that link to owner "user@host").

(cherry picked from commit 1628125bcb)
2025-11-21 11:39:01 -05:00
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
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
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