4022 Commits
Author SHA1 Message Date
Flarette de5a1df482 fix(compiler): report errors at arrow parameters
Template type checking dropped every TypeScript diagnostic that started
at an arrow function parameter. For example, with a component method
`takes(fn: (x: number) => number)`, the template expression
`takes((value) => () => 1)` compiled without the TS2345 error that
TypeScript reports at `value`.

(cherry picked from commit 9731822b27)
2026-11-09 22:34:08 +00:00
Jessica Janiuk 30aee51dcd fix(compiler-cli): fix compliance test golden and ignore missing input sourcemap on 22.2.x
When Babel 8 was introduced, Babel started resolving input source maps from
source mapping URL comments on disk by default unless inputSourceMap is explicitly provided.
In the linked compilation compliance tests, the virtual test files do not exist on the real filesystem,
which led to ENOENT errors when Babel attempted to read non-existent source map files.
This change maps sourceMap to Babel's inputSourceMap format and defaults to false when no source map is provided.

Additionally, updates the literal_void.js golden test case to use the standard ellipsis matcher (// ...)
for the component declaration, matching the emit convention on 22.2.x.
2026-11-09 13:12:37 -08:00
lazerg 97fbca6a35 fix(compiler): handle void expressions in constant literals
Array and object literals whose entries are all constants get pooled
through `GenericKeyFn.keyOf`, which had no case for `VoidExpr` and threw
when a `void` expression appeared inside such a literal.

(cherry picked from commit f9fe21d67f)
2026-11-09 18:52:46 +00:00
Angular Robot e16acdce3c build: lock file maintenance
See associated pull request for more information.
2026-10-28 13:08:15 -07:00
jhjh1214 4e4df4a696 fix(compiler): report errors for malformed template literal interpolations
The expression parser silently discarded any tokens that followed the
expression inside a template literal interpolation. For example,
`${a b}` was parsed as `${a}` and `${flags & 1}` as `${flags}`, without
a diagnostic. A template literal with an interpolation that was never
terminated was also accepted, because its lexer error was skipped in the
same way.

`parseTemplateLiteral` used a catch-all `advance()` to consume the `}`
that closes an interpolation, which also consumed anything else that was
left over. The closing brace is now expected explicitly, before
`rbracesExpected` is decremented so that error recovery still stops at
the brace of the interpolation, and lexer errors are reported.

Templates that were previously accepted with the extra tokens dropped
(or with an unterminated literal) now fail to compile with a parse
error. Valid expressions are not affected.

(cherry picked from commit 8ffc232bbf)
2026-10-24 13:54:54 -07:00
aparziale 646e9723db fix(language-service): resolve symbols for inputs with restricted access
When `strictInputAccessModifiers` is disabled (the default, even with
`strictTemplates`), bindings to input fields with restricted access
(private/protected/readonly) are type-checked through a temporary
variable rather than by assigning to the field directly. The type of
this variable was generated as an indexed access type
`(typeof _t1)["fieldName"]`, which TypeScript does not treat as a
reference to the class member. As a result, quick info, go to
definition, find references and rename did not work for such inputs,
e.g. for `readonly` signal inputs.

The type of the temporary variable is now generated as a type query
with a qualified name, `typeof _t1.fieldName`, which TypeScript
resolves as a regular reference to the class member. Reading a
private/protected field through the type query is an access violation,
so diagnostics are ignored for the type node, while the assignment into
the temporary variable remains fully type-checked. The symbol builder
now resolves the input symbol through the temporary variable's
declaration instead of bailing out.

Fixes #58284

(cherry picked from commit 1445af58e6)
2026-10-22 15:24:47 -07:00
lazerg 4b82200c4e fix(compiler-cli): require @jridgewell/sourcemap-codec 1.6.0 or later
The bundled magic-string 1.x imports `encodeRangeMappings`, which only exists since 1.6.0, so loading the compiler crashed when an older version was installed.
2026-10-21 09:07:55 -07:00
Amine 54f3de517c fix(compiler): check @boundary blocks in the control flow content projection diagnostic
Like `@if`, `@for` and `@switch`, a `@boundary` block copies the tag name
and attributes of its single root node, so the node can be projected into a
specific `ng-content` slot. The `controlFlowPreventingContentProjection`
diagnostic (NG8011) didn't look at `@boundary` blocks though, so an element
next to a second root node was silently projected into the default slot.

`@error` blocks are left out on purpose: they don't copy the tag name and
attributes of their root node, so the diagnostic's suggestions wouldn't apply.

Fixes #71288
2026-10-14 13:04:31 -07:00
Kristiyan Kostadinov fa21d083fe fix(compiler-cli): inline tcb when depending on local directive
Adds some logic to inline the TCB when depending on a directive in the same file that isn't exported.

Fixes #71291.

(cherry picked from commit 0a77018368)
2026-10-12 23:09:30 +00:00
Matthieu Riegler 6fa2b083e6 refactor(compiler): remove img/video src attribute from the URL security context.
Browsers are already blocking script execution on those attributes.

(cherry picked from commit 439ff1bdf4)
2026-10-07 18:02:32 +00:00
Alan Agius f43c63f70c perf(compiler-cli): optimize missing directive extended checks
Extended diagnostics for `missingStructuralDirective` and
`missingControlFlowDirective` previously queried `getSymbolOfNode()` to
determine whether any directives matched a template node.
This caused the template type checker to lazily generate and traverse the
full Type Check Block (TCB) AST and symbol graph for every template node
checked, introducing noticeable build time overhead in large applications
with many components and structural directives.

(cherry picked from commit b9f7c1fe82)
2026-10-07 13:56:49 +00:00
Amine 725ffcf4fa fix(compiler): match namespaced root nodes of control flow blocks against ng-content tag selectors
When a control flow block has a single root element, its tag name is copied onto
the block's template so the block can be projected into the matching
`ng-content` slot. The tag name was copied with its namespace prefix, so an
`<svg>` or `<math>` root ended up as `:svg:svg` or `:math:math` and never
matched a tag selector like `select="svg"`, falling back to the default slot.

Strip the namespace prefix like we already do for regular elements and
structural templates.

Fixes #71162

(cherry picked from commit 0244a1cb31)
2026-10-06 22:02:12 +00:00
Amine 0474258a5a fix(compiler): ignore @let declarations in the control flow content projection diagnostic
The `controlFlowPreventingContentProjection` diagnostic (NG8011) counted `@let`
declarations as root nodes of a control flow block, so a block like
`@if (x) { @let a = 1; <div foo>{{a}}</div> }` was reported as preventing
`<div foo>` from being projected into its slot. The compiler skips `@let`
declarations when it picks the node to project (since #58607), so the node is
projected correctly and the warning is a false positive.

Skip `@let` declarations when counting root nodes, like the compiler does.

Fixes #71172

(cherry picked from commit 439d495aaa)
2026-10-06 16:59:25 +00:00
Shuaib Hasan Akib 01949c53a6 fix(compiler-cli): don't mark constructor parameter properties as inherited
A member was considered inherited when its declaration's parent was not
the class being extracted. A public constructor parameter property
(`constructor(public snapshot: ActivatedRouteSnapshot) {}`) is extracted
as a property, but its declaration is a parameter whose parent is the
constructor rather than the class, so the check always matched and every
such member was tagged as inherited.

In the API reference that tag is rendered as `override`, which produced
class signatures like:

  class ActivationStart {
    constructor(snapshot: ActivatedRouteSnapshot);
    override snapshot: ActivatedRouteSnapshot;
  }

even though the class doesn't extend anything.

The check now resolves a parameter property to the class declaring its
constructor, so only members actually coming from a parent class keep
the inherited tag.

(cherry picked from commit 8dd33e726b)
2026-10-02 18:56:37 +00:00
Kristiyan Kostadinov fef7dccb5e refactor(compiler-cli): move indexer into compiler
Moves the indexer code from `@angular/compiler-cli` to `@angular/compiler` so we can reuse its code easier and because it doesn't have any TypeScript API dependencies.

(cherry picked from commit 089884487b)
2026-10-01 18:33:46 +00:00
Matthieu Riegler 97e57157e4 fix(compiler): correctly match directives on <ng-template> nested in various namespaces
With this commit with correctly detect directive attached to ng-templates in namespaces

fixes #70471

(cherry picked from commit a9d6b2fff9)
2026-10-01 18:33:25 +00:00
jhjh1214 39ef1dc3b0 docs: add pages for the NG8011 and NG8112 diagnostics
controlFlowPreventingContentProjection (NG8011) and unusedLetDeclaration (NG8112) can be
configured under extendedDiagnostics.checks, but neither had a details page. The NG8112 message
links to extended-diagnostics/NG8112, which currently resolves to the angular.dev home page.

Add a page for each. NG8112 goes under extended-diagnostics like the other configurable checks.
NG8011 is in the 80xx range of ErrorCode, which is for compiler errors documented under
adev/src/content/reference/errors, so its code is flipped to -8011 to match every other
documented code in that decade, which is what makes the compiler add the guide link, and its page
goes under errors instead.

(cherry picked from commit a32cd1ad7f)
2026-09-29 21:14:10 +00:00
Alan Agius fe9ebf5bf5 fix(compiler-cli): support extendedConfigCache in readConfiguration
Pass `extendedConfigCache` to `ts.parseJsonConfigFileContent` and consult the cache in `readConfigFile` when reading configuration files.

In Angular CLI watch mode, re-reading and re-parsing extended tsconfig files on every file change causes unnecessary disk I/O and CPU overhead. Reusing TypeScript's `extendedConfigCache` avoids adding extended config files to watchers and eliminates redundant configuration parsing on rebuilds.

Additionally, simplify `readConfiguration` by invoking `ts.parseJsonConfigFileContent` before `readAngularCompilerOptions`, caching merged `angularCompilerOptions` on `extendedConfigCache` entries, and utilizing the resolved `extendedConfigPath` to bypass redundant module resolution.

(cherry picked from commit 0f1e216b94)
2026-09-29 19:07:45 +00:00
Matthieu Riegler 82a930db40 refactor(compiler): cleanup complier flags
- checkQueries was unused
- use explicit `true` for the flags that are enabled by `strictTemplates`.

(cherry picked from commit 516170741d)
2026-09-28 21:57:12 +00:00
Kristiyan Kostadinov 0ecaf8e7ab fix(compiler): add explicit return types to generated functions
Adds `any` as an explicit return type to every function we output. This allows us to avoid some deoptimization internally.

(cherry picked from commit cda89626e8)
2026-09-28 19:44:11 +00:00
Kristiyan Kostadinov 21851fc3a3 fix(core): add debugName on afterRenderEffect
Adds a `debugName` to `afterRenderEffect` to match `effect`.

(cherry picked from commit 846c73d52b)
2026-09-24 19:32:21 +00:00
Matthew Beck 18edb1b0be fix(compiler): guard unverified ctor parameter types in class metadata
In local compilation mode the compiler can emit a reference to a symbol that it
was not able to prove has a value at runtime, because deciding that can require
information from other files. The generated factory already guards those
references with a `@ts-ignore`, but the `ctorParameters` callback passed to
`setClassMetadata` does not, so the same symbol ends up guarded in one place and
unguarded a few lines later in the same file. Type checking the generated code
then fails on the unguarded reference.

Constructor parameters are now handed to `@angular/compiler` in a structured
form rather than as an already-built callback, which lets the compiler attach a
suppression directly to the `type` property assignment of each parameter that
needs one. Only references that reflection could not verify are guarded: full
compilation resolves every reference, so its output is unchanged, and partial
declarations are published as JavaScript and never type checked, so they are
never guarded either.

Producers that build the callback themselves keep passing an expression, which
is emitted untouched.

(cherry picked from commit c92ed082ea)
2026-09-22 16:05:39 +00:00
Suraj Yadav 7a58550089 fix(forms): create controls before listeners
Create form controls before registering template listeners so custom control values are synchronized before user callbacks run. Cover Signal Forms, reactive forms, and template-driven forms.

(cherry picked from commit 6688a3d550)
2026-09-21 17:23:44 +00:00
Kristiyan Kostadinov 710c2c7857 fix(compiler): avoid hitting TypeScript limits if template has many translations
Currently each i18n expression involves declaring a variable and `if`/`else` blocks that assign to that variable. These expressions are inlined inside the `consts` of a component. The problem is that if there are many i18n expressions in a template (seems to be ~600), we end up hitting TypeScript's control flow analysis limit which produces an error.

These changes resolve the issue by detecting when we've extracted more than 250 messages (to be safe) and any remaining translations into separate functions.

(cherry picked from commit a2e62f6824)
2026-09-17 21:00:42 +00:00
Kristiyan Kostadinov e20a92c2cc fix(compiler): add return type to pure functions
Fixes that pure functions didn't have a return type which can result in compiler errors when type annotations are enabled.

(cherry picked from commit 4dc176ed97)
2026-09-17 17:15:14 +00:00
Kristiyan Kostadinov 08bf93286d fix(compiler-cli): output function return types in linker
Fixes that the linker was ignoring the return types of function nodes, instead of outputting them.

(cherry picked from commit d7dd34fd6a)
2026-09-17 17:15:14 +00:00
Matthieu Riegler 2cf24734da refactor(compiler): enable checkUnclaimedEventNames by default for g3.
We'll enable it by default for 3P in the next breaking change window.

(cherry picked from commit e6239827c7)
2026-09-17 16:09:33 +00:00
aparziale 312e1d8089 feat(compiler-cli): add strictUnclaimedEventNames option to catch misspelled output bindings
Adds an opt-in type-checking option that reports event bindings on
elements with matched directives whose name matches neither an output
of the matched directives nor a known native DOM event.

Since the compiler cannot know the set of custom events that may bubble
up from descendant elements, the check is heuristic: only
single-identifier camelCase names are reported. Dash-separated names,
which bubbling custom events conventionally use, native DOM events
(compared ignoring case, to cover vendor-prefixed names such as
webkitAnimationEnd), key pseudo-events and targeted events are exempt.
With CUSTOM_ELEMENTS_SCHEMA, elements without a matched component are
exempt as well; NO_ERRORS_SCHEMA disables the check entirely.

The option is opt-in everywhere for now; enabling it by default under
strictTemplates inside google3 (via the sync markers) will follow once
the google3 cleanup is complete.

Related to #43603
2026-09-16 16:43:46 +02:00
Kristiyan Kostadinov ffa6091e30 build: update utility scripts to account for pnpm 12
Updates the various scripts that we have to account for breaking changes in pnpm 12.
2026-09-16 14:54:37 +02:00
Andrew Scott 37ca679192 Revert "fix(compiler): wrap @for collection expression before appending non-null assertion"
This reverts commit ed8f16c078.

This caused a breakage in TGP because the changes (correctly) produced new
diagnostics on ` @for (a of (x | async) || []; track a) {` x is `any`. This
results in `<any> | async` which produces `unknown | null` and then the `@if`
finally narrows this down to `{}` which isn't iteratable.
2026-09-11 10:05:15 -07:00