3925 Commits

Author SHA1 Message Date
P4 534fe81a89 fix(compiler-cli): apply debugName transform to required signal queries
Transform assumed `.required` functions always take options as the first argument.
This is true for `input` and `model`, but not for `viewChild` and `contentChild`,
which take the same arguments as non-required versions.

Change the code to put options for signal queries in the right position,
causing debugName to be correctly generated for signal queries.

(cherry picked from commit eb2a8ff63f)
2026-07-07 11:05:28 -07:00
arturovt f5e69de1e0 refactor(compiler-cli): use BindingType enum check in suffix-not-supported extended diagnostic
Replaces the `node.keySpan.toString().startsWith('attr.')` string allocation in the `suffixNotSupported` extended template check with an O(1) `node.type === BindingType.Attribute` enum comparison.

The diagnostic message string is also extracted to a module-level constant so it is created once at module load time instead of on every diagnostic emit.

Additionally, this change adds missing test coverage for the `.%` and `.em` suffixes, as well as for a plain `attr.` binding without a style suffix.

Measured with a 100-iteration microbenchmark before and after the change (MacBook Pro 2018, Intel CPU):

```ts
const start = performance.now();
for (let i = 0; i < 100; i++) {
  new ExtendedTemplateCheckerImpl(templateTypeChecker, program.getTypeChecker(),
    [suffixNotSupportedFactory], {}).getDiagnosticsForComponent(component);
}
console.log((performance.now() - start) / 100, 'ms/iter');
```

Before: `~0.24 ms/iter`
After: `~0.14 ms/iter` (~40% faster)
(cherry picked from commit ab618bdc0f)
2026-07-07 10:05:10 -07:00
cexbrayat 3b08201bfb fix(compiler-cli): detect uninvoked signals in bound expressions using ternary
Extend the interpolated signal extended diagnostic to inspect ternary-bound expressions and report uninvoked signal reads in bound bindings.

```
<div [style.width]="width() ? 1 : width"></div>
```

where the false branch should invoke the signal as `width()`.

(cherry picked from commit eac363e92e)
2026-07-07 10:01:55 -07:00
Matthieu Riegler fd4ddcafed fix(compiler): use regular optional chaining expression for safe function calls in TCBs
Optional return types should not report non-nullable optional chaning on function calls.

fixes #69609

(cherry picked from commit 997b772f28)
2026-07-06 14:02:44 -07:00
Andrew Scott c3be83cfe1 refactor(core): allow AnimationClassBindingFn to return undefined or null
The AnimationClassBindingFn type was too restrictive, only allowing `string | string[]`. However, the runtime (`getClassListFromValue`) safely handles `undefined` and `null` values by treating them as no animation.

This change updates the type to allow `undefined` and `null`, which is consistent with other class/style bindings in Angular and avoids requiring workarounds (like empty strings) in host bindings.

Added a compliance test case to verify that `[animate.enter]` with a potentially `undefined` value compiles correctly.

(cherry picked from commit a7bde662c3)
2026-06-30 17:28:04 -07:00
Alex Rickabaugh af7edd90ca Revert "fix(compiler-cli): include toSignal in debugName transform"
This reverts commit 165995285c. Reason: breaking
in g3 (ngDevMode not defined)

(cherry picked from commit a5f1b20373)
2026-06-30 13:24:21 -07:00
Paweł Maniecki baf09a9939 fix(compiler-cli): include toSignal in debugName transform
the toSignal function received a debugName option in 0812ac3bec,
but was not covered by the signalMetadataTransform which sets the debugName in dev mode
automatically.

(cherry picked from commit 165995285c)
2026-06-29 14:32:22 -07:00
aparziale 06d854929c fix(compiler-cli): report diagnostic instead of crashing on malformed host binding
`parseHostBindings` throws plain `Error`s for malformed host bindings
(e.g. a property binding with a non-static value, as can happen while
editing in the language service). These were uncaught during directive
analysis, crashing the compiler and the Angular Language Service.

Wrap the call and surface the error as a `FatalDiagnosticError` so it
becomes a diagnostic and analysis can complete normally.

Fixes #69106

(cherry picked from commit 8b2785b597)
2026-06-24 12:14:27 -04:00
Angular Robot 6ff26e96e4 build: update babel monorepo to v7.29.7
See associated pull request for more information.
2026-06-24 10:35:42 -04:00
Alex Rickabaugh ffbbbf9129 refactor(compiler): add support for @Input transforms under isolatedDeclarations
Adds support for `@Input` transform functions in isolated declarations mode (`emitDeclarationOnly: true`), allowing components and directives to specify `transform` functions without triggering fatal compiler errors.

Synthesizes the `ngAcceptInputType_` write type syntactically:
- For referenced functions (`transform: booleanAttribute`), emits `Parameters<typeof booleanAttribute>[0]`, relying on downstream template type checking to resolve the type.
- For inline functions (`transform: (v: string) => boolean`), extracts `parameters[0].type` directly from the local TypeScript AST.

(cherry picked from commit 86ade07de6)
2026-06-16 17:27:23 +00:00
Alex Rickabaugh 568bd3a816 refactor(compiler): add support for host directives under isolatedDeclarations
Removes restrictions around using external references and local directives in `hostDirectives` under isolated declarations mode (`emitDeclarationOnly: true`).

By wrapping the host directive reference in a `WrappedNodeExpr`, TypeScript's declaration emitter seamlessly emits `typeof hostReference.node`, preserving existing imports or local identifiers exactly as authored. Also adds support for translating `PropertyAccessExpression` inside `WrappedNodeExpr` into `QualifiedName` for `.d.ts` emission, ensuring namespace imports (`import * as n from './dir'`) are preserved correctly.

(cherry picked from commit 5d2b1c4100)
2026-06-16 17:27:23 +00:00
SkyZeroZx b32ee7ceb3 fix(core): treat iframe credentialless as security-sensitive
Mark the iframe `credentialless` attribute as security-sensitive so dynamic
bindings are handled consistently with other iframe attributes that affect the
initial navigation, such as `sandbox`, `allow`, `referrerPolicy`, `csp`, and
`fetchPriority`.

Because `credentialless` must be present before the iframe starts loading to
affect the navigation’s credential mode, late dynamic updates can leave the final
DOM looking correct while the initial request was not loaded credentiallessly.

(cherry picked from commit 0152e3cbdf)
2026-06-16 16:05:57 +00:00
Andrew Scott fef8bcfb38 refactor(compiler-cli): Export indexer API for use in hybrid analysis
exports indexer API for use in hybrid analysis

(cherry picked from commit 83622ee519)
2026-06-15 18:53:40 +00:00
Andrew Scott be45e8e7cb refactor(compiler-cli): Change indexComponent file to be fileUrl
We do not need ParseSourceFile which contains the whole content. Only the file url is ever used.

(cherry picked from commit 21fccd4038)
2026-06-15 17:56:55 +00:00
Andrew Scott 06e9dbf9a5 refactor(core): ɵɵgetInheritedFactory should accept abstract type
An abstract component or directive can extend another class, meaning
ɵɵgetInheritedFactory needs to allow abstract

(cherry picked from commit 2112edefe1)
2026-06-15 16:22:39 +00:00
Andrew Scott 0f68807836 refactor(core): ComponentDef should allow abstract types too
d1539a8513 incorrectly assumed components wouldn't be abstract but
it is still possible (though probably should be an abstract directive instead).

(cherry picked from commit 8984c59626)
2026-06-11 20:08:13 +00:00
Andrew Scott 4b0c3b8b8f refactor(core): Update registerNgModuleType to support codegen typechecking
Updates types and adds test for source->source transformation with tsc downstream

(cherry picked from commit d25d2e1524)
2026-06-10 17:53:00 +00:00
Andrew Scott 01ea640539 refactor(core): Fix DirectiveDefinition interface to allow abstract classes
Interface should permit abstract classes since directives can be abstract

(cherry picked from commit d1539a8513)
2026-06-09 23:21:08 +00:00
SkyZeroZx 393b84caf8 fix(compiler): sanitize two-way properties
Apply schema-derived sanitizer resolution to TwoWayProperty ops so native two-way DOM bindings emit the same sanitizer as one-way property bindings.

Add compiler compliance coverage for innerHTML, srcdoc, URL, resource URL, and security-sensitive attribute cases.

(cherry picked from commit 3c70270c96)
2026-06-08 20:12:27 +00:00
cexbrayat 3d9ca2f173 fix(compiler-cli): bind switch exhaustive check expressions
Ensure switch exhaustive check parameters are visited during template binding so local template symbols are resolved correctly.

This allows:

```html
@let state = this.state();
@switch (state.mode) {
  @case ('show') { {{ state.menu }}; }
  @case ('hide') {}
  @default never(state);
}
```

(cherry picked from commit e8430032e1)
2026-06-03 19:02:59 +00:00
Kristiyan Kostadinov a56f1cdf8f fix(compiler): more robust logic to check if regex can be optimized
Currently we only skip regex optimization if it has the `g` flag, however regexes can also have a state with the `y` flag.

These changes move to an allowlist model where we only optimize for a set of know flags.

(cherry picked from commit 636cc94105)
2026-06-03 18:53:41 +00:00
Kristiyan Kostadinov 2891f7e787 fix(compiler): move projection attributes into constants
We can save some memory by moving the `attrs` passed into the `projection` instruction into the constant pool.

(cherry picked from commit f0b28f6443)
2026-06-01 12:28:36 +02:00
RonGamzu d9c38e552d docs: fix typos in source code comments
(cherry picked from commit 6f56202755)
2026-05-27 11:18:27 -07:00
Alan Agius a97d5ec22d build: update minimum supported Node.js versions
Update the minimum supported Node.js versions for v22 and v24. Specifically, the minimum supported version for Node.js v22 is bumped to v22.22.3, and for v24 it is bumped to v24.15.0. This ensures compatibility with newer runtime versions and coordinates ranges across monorepo packages.

(cherry picked from commit 861d37e669)
2026-05-27 10:39:21 -07:00
Alex Rickabaugh 2200b4a854 refactor(compiler): add support for compiling NgModules under isolatedDeclarations
This commit adds support for compiling NgModules in isolated declarations mode.

(cherry picked from commit 06b004ec5c)
2026-05-22 14:00:23 -07:00
Alan Agius b2b8dea732 fix(compiler): strip namespaced SVG script elements during template compilation
Ensures that namespaced <script> elements (such as :svg:script) are correctly classified as PreparsedElementType.SCRIPT by the template preparser and stripped during compilation to prevent potential XSS vulnerabilities. Consequently, obsolete security schema mappings and runtime sanitization checks for <script> attributes have been removed since these elements are never present in compiled template outputs.

(cherry picked from commit 90494cd909)
2026-05-19 13:06:06 -07:00
Matthieu Riegler efa2267394 docs(docs-infra): Show function args
With this change non-overloaded functions also show the params + return type in a dedicated block.

(cherry picked from commit 872853fbcb)
2026-05-18 13:22:34 -07:00
Andrew Scott 1630d8f8e9 refactor(compiler-cli): Remove unused properties of IndexedComponent interface
These properties aren't used in the Kythe indexer and can be removed

(cherry picked from commit 13911b156b)
2026-05-15 10:38:03 -07:00
Kristiyan Kostadinov ccb7d427e4 fix(compiler): type check invalid for loops
Currently if a `@for` loop doesn't have a `track` expression we don't produce an AST for it at all which means no type checking and language service support for it.

These changes make it so we produce the AST anyways since it gives the user more tools to resolve the issue (e.g. autocompletion when writing the `track` expression).

(cherry picked from commit 06f6dec7aa)
2026-05-13 11:26:46 -07:00
Matthew Beck c6aa402d0f Revert "refactor(compiler-cli): drop @ts-ignore around fs.readFileSync"
This reverts commit e0593ecc8b.

(cherry picked from commit 7ff4847e03)
2026-05-12 15:20:59 -07:00
Kam a4ec2b49ce refactor(compiler-cli): drop @ts-ignore around fs.readFileSync
The `readFileBuffer` method in `node_js_file_system.ts` was wrapped in
`@ts-ignore` to suppress a TS2322 Buffer/Uint8Array typing error that
was fixed in the TypeScript 5.9.2 upgrade. The minimum supported
TypeScript is now 6.0, so the suppression is dead.

(cherry picked from commit e0593ecc8b)
2026-05-12 13:21:57 -07:00
Kam ba79f263a1 refactor(compiler-cli): replace forEach with for...of in entry_point
Convert four `.forEach()` calls in `private_export_checker.ts` and
`reference_graph.ts` to `for...of`, matching the iteration style used
elsewhere in the compiler. The TODOs that forced these workarounds are
obsolete.

(cherry picked from commit e661f4d255)
2026-05-11 18:29:07 -07:00
Kam 295e4826a2 refactor(compiler-cli): drop @ts-ignore around jsDocParsingMode
The getters and setters for jsDocParsingMode in `host.ts` and
`ts_create_program_driver.ts` were suppressed with @ts-ignore to
support TypeScript 5.2, which lacked the property on `ts.CompilerHost`.
The minimum supported TypeScript is now 6.0, and `jsDocParsingMode`
is part of the public TypeScript API, so the suppressions can go.

(cherry picked from commit 7a146238ba)
2026-05-11 12:40:30 -07:00
Matthieu Riegler 78ec99d146 docs(docs-infra): improve api docs extraction
This allows us to show the API docs when the jsdoc block is at the top of a overloaded function (and not on the implementation signature).

eg: `injectAsync`
(cherry picked from commit 7360c1da68)
2026-05-11 12:03:44 -07:00
SkyZeroZx 729a9130e7 docs: add documentation for de-duplicate host directives
(cherry picked from commit 307723a352)
2026-05-07 16:53:46 -07:00
Matthieu Riegler ad717dff1d refactor(core): use the @Service decorator where possible.
A few bytes to win.
Added only on the services that don't rely on constructor DI.

(cherry picked from commit a7dab601fa)
2026-05-07 16:03:34 -07:00
Alan Agius 6f525245cd fix(core): disallow event attribute bindings in host bindings unconditionally
Moves the event attribute validation check outside of `ngDevMode` in the `elementAttributeInternal` instruction to ensure that bindings to event attributes like `on*` are always blocked at runtime.

(cherry picked from commit 5b421c61cd)
2026-05-07 15:19:27 -07:00
Andrew Scott aa1859689c refactor(compiler): Update indexer API to be generic
Rather than requiring TS AST in the indexer API, this update makes it generic with adapters to provide necessary information. This allows other analysis pipelines that don't use TS AST to work with the indexer.

(cherry picked from commit bc655d006f)
2026-05-07 15:17:05 -07:00
Leon Senft 1f30aacbe5 refactor(forms): bind formatted date string to min/max for minDate/maxDate (#68001)
* Test that `minDate`/`maxDate` binds to `min`/`max` on date and time inputs
* Test that `min`/`max` attribute can be set directly on date and time inputs
* Relax type checker to allow `min`/`max` bindings on date and time inputs

PR Close #68001
2026-05-06 11:59:18 -07:00
Alan Agius b8d3f36ed9 feat(compiler-cli): add support for Node.js 26.0.0
Updates the supported Node.js engine versions to include Node.js 26.

This allows running the CLI on Node.js 26.0.0 and above while continuing to support active LTS versions.
2026-05-06 09:55:38 -07:00
Kristiyan Kostadinov b225a5d902 fix(compiler): invalid type checking code if field name needs to be quoted
Fixes that we were producing invalid TypeScript if an input with an unsafe name (e.g. `aria-label`) is coerced.
2026-05-05 09:34:26 -07:00
Angular Robot 4f048e7de3 build: update dependency typescript to v6.0.3
See associated pull request for more information.
2026-05-04 13:05:58 -07:00
Matthew Beck 0fa8f98f4f test: add NgModule compliance test with 'bootstrap' & local compilation
There was not a test demonstrating local compilation with the
'bootstrap' param on NgModule. This test adds one, among other NgModule
fields in one. These other fields are broadly covered already, but this
rolls them into one test exercising all fields.
2026-05-01 15:58:05 -07:00
SkyZeroZx 11721509b0 refactor(core): Makes @defer(hydrate ...) runtime tree-shakable
This commit updates `@defer` logic related to incremental hydration to be tree-shakable.

If hydrate triggers are used in a `@defer` block, the compiler emits a single top-level call to `ɵɵenableIncrementalHydrationRuntime`, placed once per create block before the first `ɵɵdefer` that requires it.

As a result, the incremental hydration runtime is only included in the bundle when hydrate is explicitly used.
2026-05-01 15:54:55 -07:00
Alex Rickabaugh a4145dea06 Revert "fix(language-service): Add support for @Input with transforms"
This reverts commit dc9c72da9b. Reason: breaking
targets in g3.
2026-05-01 11:05:56 -07:00
Matthieu Riegler dc9c72da9b fix(language-service): Add support for @Input with transforms
Prior to this change @Input with transforms were not linked by language service and you couldn't navigate on it.
2026-04-30 15:51:48 -07:00
Andrew Scott 2eae497a04 feat(compiler-cli): support external TCBs with copied content in specific mode
This change adds a new  that allows environments that cannot support inline TCBs (such as the language service or source-to-source transforms where TS compilation and emit are downstream) to still perform template type checking.

    Instead of inlining the TCB into the original source file when non-exported symbols are referenced, we now copy the file content to the .ngtypecheck.ts shim file and generate the external TCB there, if requested by the inlining mode. This preserves the local scope of the original file while keeping the original file unmodified.
2026-04-29 16:08:33 -07:00
Andrew Scott c70625e806 refactor(compiler-cli): remove reflectionhost from environment
all necessary info is already available in the tcb meta objects. environments without full ts program no longer need a reflectionhost for tcb generation
2026-04-29 13:36:21 -07:00
Matthieu Riegler 37ec63e745 refactor(compiler): introduce default constant for legacyOptionalChaining flag
This will help patch the value in G3 to help land this change.
2026-04-29 10:01:13 -07:00
Matthieu Riegler 2896c93cc1 feat(compiler): Angular expressions with optional chaining returns undefined
To mitigate this breaking change,  this behavior can be disabled by wrapping expressions with the `$null` magic function.
: `$null(foo?.bar?.baz)`
2026-04-28 15:26:53 -07:00