Bundler-backed AnalysisHost implementations resolve dependencies into both in-bundle modules and
bundle-external dependencies, distinguish runtime imports from type-only imports, and assign opaque
virtual module IDs that are not filesystem paths. Previously, the query engine assumed every
extracted specifier had uniform type-only semantics, treated resolved modules as in-project paths
unless they ended in .d.ts, and computed relative paths across emitted imports and debug metadata.
Classify extracted static imports, re-exports, dynamic import() expressions, and TSImportType
queries with exact ImportKind and type_only flags and forward both on ResolveRequest. Track
authoritative external module flags in FileIdInterner and QueryEngine so external modules pass
external = true to AnalysisHost::load, stay out of ProgramFiles, coordinator roots, and core
compilation, and preserve or rebase their original OwningReference specifiers instead of emitting
paths to resolved external files.
Propagate IdKind onto AnalysisResult, FileUpdate, FileInvalidation, and WASM ModuleRef entry
points. When either side of a reference or a compiled file carries IdKind::Virtual, emit the module
ID verbatim across cross-file import emission, class debug info, and HMR identifiers without path
diffing or rootDir stripping.
Asynchronous bundler hosts suspend module resolution and content loading across
pump turns, so synchronous `*_blocking` and single-call FFI entry points cannot
run to completion within a single call. Without explicit host gating, calling a
synchronous entry point against an asynchronous host either infinite-loops or
panics inside WASM instead of reporting the host constraint cleanly.
Enforce `AnalysisHost::is_synchronous` inside `QueryEngine::block_on_query` and
add fallible `ensure_synchronous_host` checks to `Analyzer`'s synchronous core
helpers (`get_file_content_core`, `get_metadata_for_file_checked`, and
`read_resource_checked`). Route every FFI surface through them so the constraint
is reported as `"synchronous APIs require a synchronous host"` rather than a
panic: the WASM `get_metadata_for_file` and `read_resource` exports return
`Result<Option<String>, String>`, the N-API `getMetadataForFile` and
`readResource` exports return `napi::Result`, and the sidecar RPCs return an
RPC error. The WASM exports also now report a serialization failure as an error
instead of `None`.
`get_file_content_core` is gated even though it reads the filesystem directly,
because the filesystem is not authoritative under an asynchronous host. Until
pump-driven equivalents exist, `getFileContent` and `readResource` are
unavailable under an asynchronous host; pump-driven analysis, metadata queries,
and cache mutations continue working. Behavior under `DefaultFsHost` is
unchanged.
Previously, `WasmAnalyzer.getMetadataForFile` called the synchronous
`getMetadataForFile` WASM export directly, stepping the query engine to
completion inside a single FFI call. When an asynchronous `AnalysisHost`
suspends module resolution or content loading across JavaScript round-trips,
blocking inside a single WASM export cannot yield back to the host.
Add `ModuleRef` and `QueryEngine::get_metadata_for_file_id` (tracking whether
`ParseFile` loaded a module on `ParsedFileOwner::loaded` so missing modules
return `None` under asynchronous hosts just as they do under `DefaultFsHost`).
Expose `Analyzer::request_metadata_core` and `WasmAnalyzer::request_metadata`,
emitting `metadataResult` events from `WasmAnalyzer::pump` as oneshot queries
settle.
Update the TypeScript `WasmAnalyzer` adapter so `getMetadataForFile` registers
a pending request via `request_metadata` and resolves through `pumpLoop`
alongside active analysis streams, while cleaning up in-flight requests when
`close()` is called.
Skip `close_stream` for a stream that `close()` already released, so a
consumer still waiting on that stream is rejected with the close error
rather than the engine being called after it was freed. Fail a stream on
an `analysisError` whose message is empty, and report a metadata result
that cannot be serialized as an error instead of dropping the request.
Bundler integrations and workspace reconfigurations can change how module
specifiers resolve without editing any individual source file—for example
when alias tables, export conditions, or package layouts change between
builds. While `invalidate_module_resolution` re-runs previously failed
resolutions after file creation or deletion, callers also need a way to
flush positive cached resolutions without discarding parsed ASTs.
Add `ResolutionCache::clear_all` and `QueryEngine::clear_resolution_cache`
to clear both host-internal and engine-level resolution caches and evict
queries derived from any importer's resolutions while preserving cached
`ParseFile` results. Expose `clear_resolution_cache` on `Analyzer`,
`TestAnalyzer`, `WasmAnalyzer`, and the sidecar JSON-RPC server, returning
the deduplicated list of stale module IDs while preserving virtual module
IDs verbatim instead of normalizing backslashes.
Surface `clearResolutionCache` on `IAnalyzer`, `WasmAnalyzer`,
`NapiAnalyzer`, `SidecarAnalyzer`, and `HybridCompiler`. In `HybridCompiler`,
sequence `clearResolutionCache` through the serialized update queue so
evicted analyses are dropped from the TypeScript file cache, recorded for
incremental emit, and refreshed on the following delta pass.
The preprocessor's copy of formatExtendedError also prefixed the message with its own error code. It now matches ngtsc and only carries the text and the documentation link.
We had some code we used earlier to check apps against the preprocessor. These changes clean it up since it's not used anymore and it includes dependencies on TypeScript and esbuild.
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
Remove the synchronous *Sync methods and sync-only fallbacks from
HybridCompiler, IAnalyzer, DependencyTemplates, processor, indexer,
SidecarAnalyzer, WasmAnalyzer, and NapiAnalyzer.
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.
Update the preprocessor sidecar and incremental pipeline so persistent
builds can reuse HybridCompiler and SidecarAnalyzer across runs:
- Convert numeric FileUpdateType values to string enum variant names in
SidecarAnalyzer.invalidateFiles to match ng-analyze's serde JSON
representation (same as WasmAnalyzer) and preserve workspaceName in
compilerOptions.
- Prefetch cross-file component dependency metadata and record it in
HybridCompiler.metadataByFile before computing bound fingerprints in
ensureBoundWithMetadata so sidecar mode can compute bound fingerprints
without falling back to synchronous getMetadataForFileSync.
- Add HybridCompiler.applyInvalidations and cache reused source maps
across persistent run() invocations in ngp.ts.
ngtsc's `ImportManager` names the `n`th generated namespace import `i<n>` and
passes it through the helper from `createGenerateUniqueIdentifierHelper`
(`translator/src/import_manager/check_unique_identifier_name.ts`), which moves it
to `i<n>_1`, `i<n>_2`, ... while the name is in the source file's `identifiers`
table or was already generated. TypeScript's parser fills that table with the
text of every identifier token, at any depth (`internIdentifier` in `parser.ts`).
So a nested arrow parameter `i0` moves the `@angular/core` import to `i0_1` in
both the JS and the `.d.ts`.
ngp always used `i0`, `i1`, ..., which gave different output and, for a
top-level `const i0`, a compile error because the generated references resolved
to the user's binding.
The analyzer now applies ngtsc's rule restricted to bindings
(`analyzer::imports::namespace_alias_conflicts`): the name of every symbol in
oxc's symbol table, at any depth and in any space, and of every reference that
resolves to no declaration (a global), keeping those shaped like a generated
alias. These are all the names a generated reference could resolve to instead
of the import, and reading them takes about 3% of the time a walk over every
AST node does. Generated imports only come with a compiled class, so a file
without one skips the check. The names are reported as
`AnalysisResult.namespaceAliasConflicts`, and both `ExpressionPrinter` and
`TcbImportManager` (via `generateTcbCode` when `requiresInline` is `true`, for
inline `.ngtypecheck.ts` files in `processor.ts` and `hybrid_compiler.ts`) apply
the same `allocateNamespaceAlias` helper against them so the `.ng.ts` (and from
it both JS and `.d.ts`) and inline TCBs avoid colliding with the file.
Names in the `identifiers` table that aren't bindings don't count: property and
member names, labels, JSX tag and attribute names, the foreign name in an import
or export specifier, index signature parameter names, string literals used as a
property name, element-access argument or module name, and identifiers in JSDoc.
None of them can capture a generated reference, so the output compiles, but for
them ngtsc picks a different name in both the JS and the `.d.ts`. They're listed
as a `TODO(parity)`.
ngp also reused a namespace import already in the file whose alias looked like a
generated one. ngtsc never reuses an existing import for generated code: both its
Ivy and declaration transforms use `presetImportManagerForceNamespaceImports`
(`disableOriginalSourceFileReuse: true`, `transform/src/transform.ts` and
`transform/src/declaration.ts`). That reuse is removed, so a user-written
`import * as i0 from '@angular/core'` now gets a separate `i0_1` import, as in
ngtsc.
ngtsc names the namespace imports it generates `i0`, `i1`, ... and moves one to
`i0_1` when the source file already uses the name anywhere, including a nested
parameter. It also never reuses an import the file already has, even a namespace
import named like its own.
The `namespace_alias_collisions` golden case pins the generated names for a
top-level declaration, a nested arrow parameter, user-written namespace imports
named `i0` and `i1`, and a name used only as a property name. A golden's `.ng.ts`
is what both the JS and the `.d.ts` are compiled from, so it pins the names in
both.
ngp always emits `i0`/`i1` and reuses a user-written `i0`/`i1` namespace import,
so the golden holds the plain or reused names. For the top-level `const i0` the
output doesn't type-check, which `typecheck_goldens_spec.ts` lists as a known
failure.
parseComponentTemplate previously ran the template parser twice on every
component template: once with parseOptions for runtime code generation
and eagerly a second time with diagParseOptions for TCB generation,
diagnostics, and indexing. In devmode, emitDeclarationOnly, and
cross-file DependencyTemplates lookups (which only inspect
ngContentSelectors), diagNodes is never read, so the second parse was
wasted work.
This change makes diagNodes a lazy memoized getter on
ParsedComponentTemplate so the second parse only runs when diagNodes is
actually accessed. It also skips ensureBoundWithMetadata in
HybridCompiler.prepareChunk and prepareChunkSync for single-file
devmode chunks and emitDeclarationOnly builds (populating
preparedTcbData on demand in the indexer and language service when
needed), skips re-running adaptTcbInput in prepareTcbTargets Pass 2 for
targets that were already adapted with requiresInline in Pass 1, and
reuses cached source text from compiler.fileCache in ngp.ts.
In local and declaration-only compilation, ngtsc's `extractHostDirectives`
keeps every `hostDirectives` entry or reports it. ng-analyze dropped entries
silently: an undeclared identifier, a string, or an entry it couldn't
evaluate disappeared from the emitted metadata, and an entry that depended on
another file (an imported array, a spread, a conditional, or an `inputs`
mapping) dropped the whole `hostDirectives` field.
Extract `hostDirectives` the way ngtsc does under `CompilationMode.LOCAL`:
- Without `emitDeclarationOnly`, `hostDirectives` is evaluated across the
compilation unit, so those cross-file entries resolve. Under
`emitDeclarationOnly`, only ambient `.d.ts` globals fold.
- An entry that is still dynamic is emitted verbatim when its array element
is an identifier or property access, and reports NG11003 otherwise. An
entry flagged as an unsupported expression stays flagged unless it folds to
a concrete value, since ngtsc re-anchors a dynamic value on the outermost
expression it evaluated.
- A non-array value or a non-reference entry reports NG1010, and an inputs or
outputs mapping that isn't an array yields no mapping rather than dropping
the entry.
The preprocessor recognized `@angular/core` by walking up to the nearest
`package.json` named `@angular/core`, which ngtsc never does and which a
host without file system access cannot do. Follow ngtsc's rule instead:
the internal `angularCoreCompilation` option, falling back to the
tsconfig's `_isAngularCoreCompilation`, then to an explicit
`r3SymbolsFile`, and otherwise to whether the root `r3_symbols.ts`
exports `ITS_JUST_ANGULAR = true` (ngtsc's `isAngularCorePackage`).
The `ITS_JUST_ANGULAR` check reads `r3_symbols.ts` through the query
engine, so edits to it invalidate dependent analyses. A new
pseudo-dependency on the `r3_symbols.ts` root lookup re-runs only the
queries that read it when the roots add or remove that file, instead of
every query on each root change.
Also remove the unused `resolve_to_dts` helper.
In ngtsc, an unbound identifier in Angular decorator metadata resolves
through TypeScript's global scope like any other value. An example is
Closure's `COMPILED`, declared by `declare var COMPILED: boolean` in a
`.d.ts` file listed in `tsconfig.json` `files`. ng-analyze only indexed the
`declare module` blocks in those files and treated these identifiers as
unknown. Full compilation fell back to emitting the unevaluated expression
(e.g. into `ɵɵsetNgModuleScope`), and fields that must be static reported
NG1010 (NG11001 in local compilation).
Index the ambient global values that the tsconfig's `.d.ts` files declare
(top-level declarations in script `.d.ts` files and `declare global`
blocks), and resolve unbound value identifiers against them:
- The index parses each `.d.ts` file into a recycled allocator, without
semantic analysis or caching its parse, and treats a file as a module the
way TypeScript does (`import x = require()` makes it a module;
`export as namespace` alone doesn't).
- An unbound value identifier becomes an `AmbientGlobal` hole. Only the
candidate `.d.ts` files are parsed, the name must be a value in the script
scope or a `declare global` block, and the declaration is evaluated as
ngtsc does: `declare var COMPILED: boolean` is a reference and
`declare const ENV: 'prod'` is `'prod'`. References get the consumer's
local name, so emitted code uses the bare global rather than importing
the `.d.ts`.
- In local and declaration-only compilation, `host`, `@Input`/`@Output`
metadata, and query predicates complete ambient globals while keeping
cross-file import holes. Ambient globals that no `.d.ts` declares are
demoted before validation, so they still report NG1010/NG11001.
- A declared variable whose type annotation is still pending falls back to
a reference, as in ngtsc's `visitVariableDeclaration`.
The `ngmodule_imports_spread_dynamic_entry` golden now uses a call to a
declared function instead of an ambient boolean constant. The constant now
evaluates statically (as in ngtsc), and the golden exists to cover a spread
entry that can't be evaluated statically.
ngtsc's `ImportManager` rebuilds every file it adds imports to as the file's
existing import statements, then the generated imports, then the rest of the
file. Its `isImportStatement` counts `import X = …` (and `export import X = …`)
as an import statement, so ngtsc moves those to the top of the file along with
any `import` declarations written further down. ngp only hoisted `import`
declarations and left `import X = …` where it was. When code earlier in the
file reads the alias while the module loads, such as a `providers` entry that
ngtsc compiles into the component definition, ngtsc's output works and ngp's
throws.
Collect the top-level `import X = …` statements and hoist them together with
the late `import` declarations, in source order. Like ngtsc, only hoist in a
file that gets generated imports: one with a compiled class. ngtsc leaves a
file whose classes are all `jit: true` untouched, while ngp still adds an
`@angular/core` import there, so ngp no longer hoists late `import`
declarations in such a file either.
This changes runtime behavior in both directions, each time to match ngtsc.
Code that reads an `import X = …` alias before the line it's written on now
loads instead of throwing. An `import X = Local.Y` that follows
`namespace Local {}` now moves above the namespace and reads `undefined.Y` at
runtime, as it does with ngtsc; the `imports_equals_and_non_angular_hoisting`
golden records that.
Mark references resolved via try_foreign_function_call and
mark_value_synthetic on SyntheticValue::ModuleWithProviders as
synthetic = true, matching ngtsc's StaticInterpreter
resolveForeignFunctionCall / visitFfrExpression behavior so that
ClassData::to_wire sets remote_scopes_may_require_cycle_protection and
processor.ts wraps remotely-scoped ɵɵsetComponentScope arrays in
closures.
Add evaluator, cross-file compiler, and end-to-end TypeScript remote
scoping tests covering ModuleWithProviders<T> values returned via
foreign function resolution.
Emit static ctorParameters = () => [] when a jit: true class declares an
explicit zero-argument constructor (matching ngtsc's
downlevel_decorators_transform.ts), while continuing to omit
ctorParameters when no constructor is declared.
Track fatal NgModule scope analysis failures via NgModuleData::analysis_failed
and filter failed NgModule classes out of FileData::to_wire in full compilation
mode, avoiding cascading TS6133/TS2339 errors on emitted .ng.ts files while
preserving NG6xxx diagnostics and strictInjectionParameters NG2003 validation
for co-located @Injectable() decorators.