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]>
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
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.
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.
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.
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.
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`.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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`.
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.
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.
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.