When TS emits re-exported `as const` arrays in .d.ts, it may emit something like `typeof import('...').Foo` for elements that aren't directly imported in the file. These changes update the preprocessor to resolve them correctly.
(cherry picked from commit 3492295b9a)
In normal perf tracing mode, `ngp.rust.Summary` records top-5 `slowest` entries with `file` paths read from each query span's `file` field. That field was populated from `QueryKey::file_id()`, which returns `None` for `NgModuleExportsScope(ReferenceId)` and `NgModuleImportsScope(ReferenceId)`, leaving their `slowest` entries without file paths unless detail mode was enabled.
Add `QueryKey::perf_file_id()` to return `Some(reference_id.file)` for NgModule scope queries as well, and use it in `QueryEngine::execute` when creating the perf span. Keeping `QueryKey::file_id()` unchanged avoids marking NgModule files dirty or emitting them in `invalidatedPaths` when a downstream dependent evicts a cached scope key.
(cherry picked from commit 7b50ce3be2)
Add getDefinitionForExpressionAtPosition in the preprocessor language service DefinitionBuilder, matching the ngtsc language service structure, to resolve component templateUrl and styleUrls string literals to their target files.
(cherry picked from commit a9d35bad83)
Cache the last sent document content in TsGoFacade.ensureDocument and skip sending textDocument/didChange when the content is unchanged, avoiding unnecessary cancellation of concurrent in-flight TypeScript 7 language server requests.
(cherry picked from commit b208470321)
Add VS Code launch and task configurations for launching and debugging the ngp-vscode-ng-language-service extension host in the monorepo, and fix build and runtime resolution issues when running outside Bazel:
- Add 'NGP VSCE: Launch Dev Client' and compound attach configs in .vscode/launch.json and 'NGP VSCE: build' task in .vscode/tasks.json.
- Update ngp-vscode-ng-language-service/build.js to use server/esbuild-tsconfig.json, mark @typescript/native-preview external, and define import.meta.url via banner.
- Update ngp-vscode-ng-language-service/tsconfig.json for TypeScript 7 compatibility (remove baseUrl, use relative paths, and specify node types).
- Resolve platform tsc/tsgo binary via createRequire from @typescript/native-preview/package.json so pnpm workspace layouts work, and await clientReady before sending angular/setTsApiPipe from fallback ts7Client.
- Allow analyzer_loader.ts to locate ng_analyze_wasm.js when walking up from a realpath'd bundle inside bazel-out.
(cherry picked from commit 6d49c19e22)
Upgrades the TypeScript 7 dependency in the preprocessor language service
and VS Code extension from the frozen @typescript/[email protected]
package to npm:[email protected], updates binary lookup for
@typescript/typescript-<platform>-<arch> (tsc), updates subpath imports from
/unstable/async to /async, and replaces api.updateSnapshot() with
api.getCurrentLanguageServerSnapshot().
(cherry picked from commit f442d775f0)
The `allowEmptyCodegenFiles` compiler option wasn't used and has been cleaned up internally. These changes remove the last references to it.
(cherry picked from commit f41e1d8269)
`propagate_owning_reference_validated` and `resolve_host_directive` resolve a
package entry point and compute its `ModuleExportMap` so declarations and host
directives in `.d.ts` files inherit the package's published specifier and
export name. Under `PrefixImportStrategy`, `uses_owning_reference()` is `false`
and `emit` always derives module specifiers and export names directly from each
symbol's declaring file, ignoring `owning_reference` (matching `ngtsc` omitting
`AbsoluteModuleStrategy` when `_useHostForImportGeneration` is enabled).
(cherry picked from commit b2b4b1755c)
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.
(cherry picked from commit e4807c3c0c)
Extended diagnostic messages started with their own error code, so tools that already print the code from the diagnostic showed it twice, for example `NG8021: NG8021:`. The message now only carries the text and the documentation link.
(cherry picked from commit b4b088dccd)
Previously, `QueryEngine` invoked `AnalysisHost::resolve` directly on every
syntactic dependency scan, cross-file constant evaluation, export-map walk,
and NgModule scope traversal without an engine-level cache. For asynchronous
bundler hosts, repeating identical `(importer, specifier, kind, type_only,
attributes)` lookups across queries and rebuilds would generate redundant
cross-boundary round-trips. In addition, failed module resolutions only
recorded `UNRESOLVED_IMPORTS_FILE_ID` during the Stage-1 static dependency
scan of `.ts` sources. That scan does not resolve the specifiers of `.d.ts`
files, so a failed lookup made from one, such as a re-export to a missing
target, was untracked and not re-run when the target was later created.
Deleting a resolved file also left importers holding stale cached dependency
edges.
Introduce `ResolutionCache` on `QueryEngine` to memoize completed module
resolution outcomes per importer `FileId` and request key while maintaining
both a target-to-importer reverse index and an unresolved-importer index.
Route query-time module lookups through `QueryContext::resolve_request`,
`resolve_from_id`, and `resolve_from_path` so every resolution records the
importer dependency and every failed lookup—including negative cache hits—
records `UNRESOLVED_IMPORTS_FILE_ID`. Classify pure re-exports in
`analyze_file_syntax` with `ImportKind::ReExport` so syntactic dependency
discovery shares cached resolutions with cross-file evaluation and export-map
queries.
On `invalidate_file_id`, drop only the edited importer's cached resolutions
so edits to a leaf module preserve cached resolutions across its importers.
On `FileUpdateType::Deleted`, evict queries derived from importers that had
resolved to the deleted target while keeping their `ParseFile` results
cached. On `invalidate_module_resolution`, stop serving every cached
resolution and re-run importers with previously unresolved specifiers. The
superseded entries are kept as stale rather than dropped, so the reverse
index still covers importers whose queries stay cached and that therefore do
not resolve again, and a lookup that the host answers after the change is
not memoized.
When a host resolution changes a module's `IdKind`, also evict the importers
whose cached resolutions report the previous kind. The resolution that
changed the kind is not memoized, so the query re-run that follows asks the
host again.
(cherry picked from commit 8ee9520035)
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.
(cherry picked from commit 8be02a66d3)
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
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.
When a tsconfig has no `exclude` (including through `extends`), TypeScript skips `outDir` and `declarationDir` while expanding `include` globs. ng-analyze didn't, so emitted `.d.ts` and `.js` files inside the project could get picked up as sources.
After routing module resolution, component resource resolution, and file
loading through `AnalysisHost`, the `Fs` type parameter on `QueryEngine`
and `QueryContext` no longer described any state the engine holds. It
survived only as a `PhantomData` marker, yet it still forced roughly a
hundred query, evaluator, analyzer, and compiler functions to carry a
`ResourceResolverFs + Clone + 'static` bound and kept the engine's types
tied to the filesystem implementation that hosts are meant to abstract
away.
Make `QueryEngine`, `QueryContext`, and the `QueryCtx` aliases concrete
types and remove the marker field, then drop the bound from every
function, method, and helper type that existed only to thread it
through, including the NgModule scope `ScopeEnv` and `Resolver`, the
streaming coordinator, and `DirtyFilesSnapshot`. The filesystem type now
appears only on the `new`, `new_with_options`, and `new_default`
constructors that wrap a filesystem and resolver in a `DefaultFsHost`, so
existing callers infer it as before, while `new_with_host` and
`new_default_with_host` accept any host directly. Tests that named
`QueryEngine<OverlayFileSystem>` now use the plain engine type, and
imports left unused by the removal are dropped.
Also reword the preprocessor contributor guideline on paths and module
resolution to describe the host boundary: analysis code resolves and
loads only through `AnalysisHost`, only host implementations touch a
filesystem or `oxc_resolver`, path arithmetic applies solely to
path-backed module IDs, and the TypeScript code-generation layer remains
a pure consumer of pre-resolved metadata. There is no change in
behavior.
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.
Even with `AnalysisHost` and `DefaultFsHost` available, `QueryEngine`,
component resource loaders, and cross-file constant evaluation still held
a concrete filesystem and `oxc_resolver` instance and performed synchronous
file reads and specifier lookups directly. That prevented asynchronous,
filesystem-free bundler hosts from driving analysis and left synchronous
helper entry points able to bypass the host boundary.
Replace `fs` and `resolver` on `QueryEngine` with `Arc<dyn AnalysisHost>`,
retaining a temporary `PhantomData` marker for `Fs` so generic parameter
removal across query and evaluator signatures stays isolated to a separate
follow-up change. Existing constructors wrap `DefaultFsHost` to preserve
current behavior, while `new_with_host` and `new_default_with_host` allow
injecting custom asynchronous hosts directly.
Route file parsing, syntax-level static and dynamic dependency discovery,
ambient `.d.ts` scanning, local-compilation extra import checks, export-map
traversal, host-directive package resolution, and cross-file symbol chasing
through `AnalysisHost`, deleting the synchronous `resolve_specifier` helper
so future call sites cannot bypass the host. Convert Stage-1 and Stage-2
component `templateUrl` and `styleUrl` loading to asynchronous host calls
that concurrently resolve resources and static/dynamic module specifiers in
a single wave, fall back to `AnalysisHost::load` when inline resource text
is omitted, and exclude `external` modules from the program closure while
still reading their metadata on demand.
Ambient global lookups read the tsconfig's `.d.ts` files through the host
as well, so they become asynchronous, and the lock that serializes their
scan is now an async mutex, held across host loads without blocking a pool
thread.
When a host resolution reports a different `IdKind` for a module that is
already interned, the host still wins, but whatever was computed under the
previous kind is now evicted. Queries still running at that point are not
in the reverse index yet, so any that read the module re-run before
returning, letting every caller see a result computed under the current
kind. A host that keeps flipping a module's kind stops the re-runs after
three, and the last result is returned without being cached.
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.
Moves the HMR dependency extraction logic into the `compiler` package since it's only dealing with our own AST. This will allow us to drop the dependency on `compiler-cli` from the preprocessor.
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.