1971 Commits
Author SHA1 Message Date
aparzialeandMatthieu Riegler e4f67442bb feat(compiler): report unknown property bindings on explicit ng-template elements
Previously, property bindings on `<ng-template>` that were not claimed
by a matched directive were silently ignored by the type checker. This
was inconsistent with how bindings on regular elements are handled.

This check is added behind a temporary compiler flag `checkTypeOfNgTemplateBindings` which will be removed
in the next breaking change window.

When the flag is enabled, the type checker will report an error for any property binding on an `<ng-template>` that is not matched by a directive.

Fixes #69322

Co-authored-by: Matthieu Riegler <[email protected]>
2026-11-11 15:41:43 -08:00
aparziale 08d41a9e94 fix(compiler-cli): suggest ngProjectAs in control flow content projection diagnostic
Previously, the NG8011 diagnostic suggested wrapping the content of the control
flow block in an `<ng-container/>` that matches the slot selector. This
suggestion is misleading: for element selectors (e.g. `select="my-title"`) a
plain `<ng-container>` can never match the slot, and the actual solution,
`ngProjectAs`, was never mentioned.

The suggestion now shows the exact `<ng-container ngProjectAs="...">` usage for
the matched slot selector and clarifies when to use it versus splitting the
content across multiple blocks, aligning the message with the NG8011 error page
on angular.dev.

Fixes #59398
2026-11-11 13:56:11 -08:00
Andrew Scott e1e0e3aa6e refactor(compiler-cli): migrate preprocessor language-service and tests to async APIs
Migrate preprocessor language-service, ngp-vscode-ng-language-service,
preprocessor tests, and ngp_test_driver to use the async HybridCompiler
and IAnalyzer methods instead of synchronous *Sync lookups.
2026-11-11 13:49:47 -08:00
Alex Rickabaugh 98b0f3b720 refactor(core): remove signal components prototype
Removes the unfinished prototype for signal-based components and directives
(the internal `signals: true` decorator flag):

* `@Directive`/`@Component` no longer accept the internal `signals` option.
* The compiler no longer reads it (ngtsc, JIT, linker, hybrid preprocessor)
  and no longer emits `signals: true` in definitions, `isSignal: true` in
  partial declarations, or the trailing `IsSignal` type argument of
  `ɵɵDirectiveDeclaration`/`ɵɵComponentDeclaration`.
* The runtime drops `DirectiveDef.signals`/`ComponentDef.signals`,
  `LViewFlags.SignalView` and the internal `ComponentMirror.isSignal`.

Signal inputs, model inputs and signal queries (input/query-level `isSignal`)
are unaffected.
2026-11-11 09:10:56 -08:00
Alex Rickabaugh ae9c706d14 refactor(compiler): remove selectorless prototype
Removes the experimental "selectorless" template syntax (`<MyComp>` / `@Dir(...)`)
which was never shipped. This deletes:

- compiler: lexer/parser support for component and directive tokens, the
  html `Component`/`Directive` nodes and the R3 `Component`/`Directive`
  (`TmplAstComponent`/`TmplAstDirective`) nodes together with their visitor
  methods and the `directives` field on elements/templates, the
  `selectorlessEnabled`/`enableSelectorless` parse options, direct pipe
  references (`BindingPipeType`), selectorless reference validation, the
  selectorless paths in the binder (`referencedDirectiveExists`),
  type-check ops, indexer, i18n and template pipeline.
- compiler-cli: the `_enableSelectorless` option, selectorless component
  analysis and `SelectorlessScope`, deferred selectorless dependencies,
  selectorless template symbols, out-of-band diagnostics and the related
  error codes (2024, 2025, 2026, 8018), the linker option, and the
  preprocessor/ng-analyze selectorless analysis.
- language-service: selectorless definitions, quick info, references and
  rename.
- the selectorless runtime and compiler tests.

`SelectorlessMatcher` is kept since it is used to match foreign components
(`foreignImports`) by tag name.
2026-11-11 09:10:56 -08:00
Matthieu Riegler 225d600314 fix(compiler): disallow attribute and property names starting with a colon
Previously, binding to an attribute starting with a colon (such as
`[attr.:onclick]` or `[attr.:href]`) resulted in the leading colon being
stripped by `mergeNsAndName` only after attribute validation and security
context resolution had already taken place. This allowed `[attr.:onclick]`
to bypass event attribute validation, producing an `onclick` attribute binding.

Because attribute and property names starting with a colon are invalid syntax
in HTML/XML and Angular templates, this change rejects any attribute or property
binding whose name starts with a colon immediately during validation.

In addition, namespaced event attributes (such as `[attr.svg:onclick]`) are now
properly disallowed by inspecting the local name across element schemas and host
bindings.
2026-11-10 09:42:00 -08:00
Flarette 9731822b27 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`.
2026-11-09 14:34:03 -08:00
Kristiyan Kostadinov 672b9dcfc2 fix(compiler-cli): remove nullish coalescing check
Removes the check for nullish coalescing expressions that aren't nullable, because it relies on the type checker and it won't translate to the new compiler.
2026-11-09 14:29:52 -08:00
lazerg f9fe21d67f 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.
2026-11-09 10:52:40 -08:00
Roman Khegay 36f3bfab92 docs: add error guide for NG8022
Document the unsupported form field binding error and mark its code as negative so the diagnostic links to the guide
2026-11-09 10:51:55 -08:00
Kristiyan Kostadinov b4089e5f53 refactor(compiler-cli): enable debug transform tests in preprocessor
We had the debug transform tests disabled with the preprocessor, because the shape is somewhat different in order to avoid compilation errors. These changes enable the tests by using a regex for the assertions.
2026-11-07 10:11:51 +01:00
Kristiyan Kostadinov 458303fe94 fix(compiler-cli): emit namespace imports for standalone declarations in remote scopes
When an `NgModule` imports or re-exports an in-program standalone declaration, ngtsc resolves its scope entry from the declaration's own metadata rather than the import identifier in the module file, so remote scoping emits it through a namespace import.

Previously the preprocessor kept the module file's local import alias on the reference, causing `ɵɵsetComponentScope` to emit the bare identifier instead. These changes strip the importer aliases for non-`.d.ts` standalone declarations in `NgModule` scopes to match ngtsc.

Also fixes a couple of tests that were failing due to formatting.
2026-10-30 14:22:32 +01:00
Kristiyan Kostadinov 4481364843 test(compiler-cli): enable passing tests
A few of the `@defer` block validation tests were passing, but were producing more diagnostics than ngtsc. The amount of diagnostics was an implementation detail so these changes update the assertions and enable the tests. Also moves one partial compilation test into a different bucket.
2026-10-30 14:22:32 +01:00
Kristiyan Kostadinov 0b0bb3f261 test(compiler-cli): run all ngtsc tests against preprocessor
Some ngtsc tests weren't running against the preprocessor. These changes enable them and add the failures to the known failures.
2026-10-30 14:22:32 +01:00
Kristiyan Kostadinov 9fe64d48d2 fix(compiler): avoid producing type errors for invalid @let usages
Previous we produced `undefined` when an `@let` was referenced incorrectly. This can cause type issues when the generated code is typed checked so instead we use the `invalid` instruction.
2026-10-30 07:29:52 +01:00
Kristiyan Kostadinov 8c91cf2b42 fix(compiler-cli): emit untyped inline input transforms in local mode
Matches ngtsc's behavior in the preprocessor by preserving inline decorator input transform functions even when their first parameter does not have an explicit type annotation.
2026-10-29 22:35:52 +01:00
Kristiyan Kostadinov 323495c2ec fix(compiler-cli): validate host directive in local compilation
Matches ngtsc's validation for host directives in the preprocessor.
2026-10-29 22:35:52 +01:00
Kristiyan Kostadinov 47edfd51a2 fix(compiler-cli): add validation for defer in local compilation mode
Sets up the validations for `@defer` in local compilation mode within the preprocessor.
2026-10-29 22:35:52 +01:00
Kristiyan Kostadinov c0af104b34 test(compiler-cli): enable more passing tests
Enables more tests that pass in the preprocessor, aside from some minor formatting differences.
2026-10-29 22:35:52 +01:00
Kristiyan Kostadinov 4501ff813f refactor(compiler-cli): initial implementation of incremental compilation in preprocessor
Adds an initial implementation for incremental compilation in the preprocessor. Some numbers from a benchmark running against a synthetic app made up of  20 features x 20 components + 30 shared directives/pipes/services (~500 TS files, ~400 templates):

| scenario | main | branch | delta | files processed (main -> branch) | files written (main -> branch) |
|---|---|---|---|---|---|
| cold build (fresh analyzer) | 3388 ms | **3366 ms** | −0.7% | 513 -> 513 | 513 -> 513 |
| rebuild: template edit (leaf component) | 3143 ms | **41 ms** | −98.7% | 513 -> 1 | 513 -> 1 |
| rebuild: component method body | 3144 ms | **40 ms** | −98.7% | 513 -> 1 | 513 -> 2 |
| rebuild: service method body (widely imported) | 3150 ms | **34 ms** | −98.9% | 513 -> 1 | 513 -> 8 |
| rebuild: directive public API (new input) | 3167 ms | **169 ms** | −94.6% | 513 -> 10 | 513 -> 8 |
| rebuild: NgModule scope (drop an export) | 3210 ms | **49 ms** | −98.5% | 513 -> 1 | 513 -> 2 |

**Note:** the real-world numbers will depend on build tooling integration so take these numbers with a grain of salt.
2026-10-29 17:47:21 +01:00
Kristiyan Kostadinov 7c64deacf4 fix(compiler-cli): do not emit new namespace imports for DI dependencies
Currently when something is injected, we produce a namespace import (e.g. `import * as i1`) to match ngtsc's behavior. This ends up breaking some internal builds.

These changes switch to referencing those symbols directly.
2026-10-29 13:33:03 +01:00
Matthieu Riegler 5700a5bba5 fix(compiler-cli): fix remaining NGP compliance test failures
Fix the remaining known NGP compliance failures across full compile and
declaration-only emission modes:

- Forward baseUrl and paths from compiler options into synthetic tsconfig in ngp_test_driver.ts.
- Classify quoted string literal property keys in @HostBinding and @HostListener as ExpressionValueKind::String so @angular/compiler generates KeyedRead instead of PropertyRead.
- Make PipeMetadata.name an optional string rather than falling back to class_name when unnamed, emitting null in ɵɵPipeDeclaration.
- In declaration-only emit, emit external module references (i<N>.X) for external references in isolated type tuple expressions so tsc elides unused named imports from the emitted .d.ts.
- Remove resolved test entries from NGP_KNOWN_COMPLIANCE_FAILURES.
2026-10-28 21:29:13 -07:00
Kristiyan Kostadinov 1172ba317e fix(compiler-cli): match ctorParameters behavior from ngtsc
Resolves a test failure internally where we weren't matching how ngtsc emits `ctorParameters` for primitive types. It appears that in ngtsc we have some logic where `string` gets emitted as the `String` object, `number` as the `Number` object etc.
2026-10-27 23:00:09 +01:00
Kristiyan Kostadinov 2bd42454e6 test(compiler-cli): enable more passing tests
Updates a bunch of tests that were generating correct code, but needed more lenient assertions.
2026-10-27 23:00:09 +01:00
Kristiyan Kostadinov 401cb2ec0f fix(compiler-cli): validate deferredImports
Sets up validation for the `deferredImports` field of `@Component` in a similar way to ngtsc.
2026-10-27 23:00:09 +01:00
Matthieu Riegler e36a63e20e test(compiler-cli): migrate compliance test expectations to full-file goldens
Migrate the ngtsc compliance test suite from snippet-based golden files to full-file golden files:
- Expand macro calls (__AttributeMarker, __SelectorFlags, __QueryFlags, __i18nMsg__) and $...$ identifier placeholders in compliance golden files to full-file ngtsc output.
- Format full-file compliance golden files and generated compliance outputs (`ngtsc` and `ngp`) with Prettier (`printWidth: 100`).
- Consolidate multi-snippet expectations in TEST_CASES.json into single full-file expectations and un-share shared line-ending normalization expectations so each test case has its own full-file golden, using `…` for partial-linker divergent fragments.
- Enforce start-of-file and end-of-file bounds in `expectEmit` for full-file goldens, sub-chunk large token arrays and string literals, and explicitly scope partial-linker normalizations (`isLinkedCompilation`) and NGP emit normalizations (`isNgpCompilation` / `isNgpTestMode()`) to their respective test runners.
- Align `ngp` (`HybridCompiler`) DI and class metadata emission with `ngtsc` and consolidate remaining NGP cosmetic emit normalizations into `normalizeNgpEmitForComparison`.
2026-10-27 08:19:52 -07:00
Kristiyan Kostadinov 03fee33ebd test(compiler-cli): fix tests with invalid tsconfig
ngtsc has some hidden behavior that merges `angularCompilerOptions` with the TS options. There were a handful of tests that depended on that behavior.

Also covers some goldens that I missed in previous commits.
2026-10-26 22:08:11 +01:00
Kristiyan Kostadinov 7110603992 fix(compiler-cli): handle unexported host directives
Fixes that the preprocessor wasn't reporting host directives that haven't been exported.
2026-10-26 22:08:11 +01:00
Kristiyan Kostadinov 1f0ef60125 fix(compiler-cli): avoid duplicate diagnostics on in and typeof expressions
Fixes that we were reporting duplicate diagnostics in the preprocessor if the user wrote an invalid `in` or `typeof` expression. Also fixes some order-dependent assertions.
2026-10-26 22:08:11 +01:00
jhjh1214 8ffc232bbf 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.
2026-10-24 13:54:50 -07:00