Commit graph

900 commits

Author SHA1 Message Date
Andrew Scott
d4c8a9a887 refactor(compiler-cli): decouple SymbolBuilder from BoundTarget and minimize adapter surface
Decouple `SymbolBuilder` from the full `BoundTarget` interface by introducing a purpose-built `SymbolBoundTarget` interface containing only the 4 methods required for symbol resolution. This eliminates the need for the large, pass-through `BoundTargetAdapter` and further isolates `SymbolBuilder` from compiler-internal implementation details.

Also minimize `TypeCheckableDirectiveMetaAdapter` by redefining `SymbolDirectiveMeta` to not extend `DirectiveMeta`, exposing only the properties actually used by `SymbolBuilder`.

Removed dead code `getDirectiveMeta` in `template_symbol_builder.ts` which was unused.

These changes improve maintainability and ensure a cleaner architecture by strictly defining the boundaries of what `SymbolBuilder` needs from the rest of the system.
By limiting the required inputs to only what's necessary for the implementation, we make it easier to re-use
the implementation between different compiler architectures
2026-04-08 11:59:42 -07:00
Andrew Scott
33a30e0e03 refactor(compiler-cli): Fix regressions caused by ts.typechecker removal
removing ts.typechecker in a prior refactor caused some regressions, particularly when multiple directives
appear on a single elemnt. this is now addressed by using an id for directives and storing that in the tcb comment

(cherry picked from commit 30c950f133)
2026-04-08 15:14:48 +00:00
Andrew Scott
910dcb6d6a refactor(compiler-cli): decouple TemplateSymbolBuilder from ts.TypeChecker
This updates the SymbolBuilder to no longer use ts.TypeChecker internally to
build symbols for the language service. These lookups are deferred/done later
using the newly expanded template type checker API.
2026-04-07 14:51:37 -07:00
Andrew Scott
7797671257 fix(language-service): get quick info at local var location to align with TS semantics and support type narrowing
Previously, the Language Service fetched Quick Info and definitions for template variables (such as `@let` declarations) using mapping to their `initializerLocation` (the right-hand side expression). This aggressively bubbled the type, JSDoc, and definition identity of the initializer backwards onto the variable itself.

This approach had two flaws:
1. It broke type narrowing because the LS read the original un-narrowed type from the source expression rather than the type of the narrowed intermediate variable in the Type Check Block.
2. It deviated from native TypeScript semantics, where a local `let` binding (`let address = hero.address`) does not inherit the docstrings or `(property)` kind of its initializer, acting solely as a local inferred variable.

By using `localVarLocation` rather than `initializerLocation` for LetDeclaration Quick Info and Type Definitions, these intermediate variables now properly preserve type narrowing within templates and flawlessly match the standard behavior expected of TypeScript block variables. `VariableSymbol.initializerLocation` is retained solely to map the value spans of structural directive contexts (e.g., `exportAs` strings).

fixes #65491

(cherry picked from commit 75ac120493)
2026-04-01 19:22:11 +00:00
Andrew Scott
b453c0ce67 refactor(language-service): Update getTcbNodesOfTemplateAtPosition to be usable without compiler (#67898)
updates getTcbNodesOfTemplateAtPosition to be usable without ngCompiler instance
so it can be shared with more compiler types

PR Close #67898
2026-03-26 21:32:20 +00:00
Andrew Scott
a9ca90fc11 refactor: fix types extraction for private (#67898)
fixes types extraction for private entrypoint of language service

PR Close #67898
2026-03-26 21:32:20 +00:00
Andrew Scott
a6c49e0ea9 refactor(language-service): Export template target from API
allows template target to be used in other tooling

(cherry picked from commit eecfa4c909)
2026-03-25 13:07:47 -07:00
Andrew Scott
4c86ed382d refactor(compiler-cli): abstract type check block metadata to be AST-free
This commit refactors the template type checking metadata interfaces to use detached, serializable metadata rather than retaining direct references to ts.Node or ts.Declaration instances.

A new tcb_adapter translates traditional TypeScript AST-bound metadata into these decoupled structures. This abstraction lays the groundwork for supporting native preprocessors (such as Rust or ts-go) which serialize metadata over JSON rather than passing live TypeScript objects.

Key changes:
- Introduced TcbDirectiveMetadata, TcbComponentMetadata, TcbReferenceMetadata, and TcbPipeMetadata to replace TypeCheckableDirectiveMeta where appropriate.
- Substituted deep TS compilation AST references with string module names and source spans to preserve out-of-band diagnostic capabilities.
- Detached generic typeParameters and transformType properties into synthesized, standalone TS mappings.
- Updated generateTypeCheckBlock and corresponding Operations to consume the new metadata.
2026-03-10 12:39:18 -07:00
Kristiyan Kostadinov
da57d1af73 build: use TypeScript 5.9 for patch builds
Partially rolls back to using TypeScript 5.9 for the builds on the patch branch, because we bundle our TypeScript version with the language service which can introduce unexpected breakages for users.

Note that we still allow users to install TypeScript 6.
2026-03-04 07:59:23 -08:00
kbrilla
d2137928e8 perf(language-service): use lightweight project warmup for Angular analysis
avoid per-file semantic diagnostics work when warming up a newly loaded project.
add ensureProjectAnalyzed() to the language-service API and use it from the server startup path.
implement warmup through public compiler API access with existing perf tracing, and add legacy test coverage for the new warmup flow.

(cherry picked from commit 39f62fa408)
2026-02-20 02:11:06 +00:00
Matthieu Riegler
1d4783c01c refactor(language-service): split tests to reduce risk of timeouts
Because we've had to many timeouts recently

(cherry picked from commit 550b3ba01b)
2026-02-20 02:10:34 +00:00
Matthieu Riegler
95b3f37d4a feat(compiler): Exhaustive checks for switch blocks
`@switch` blocks can now enable exhaustive typechecking by adding `@default(never);` at the end of a `@switch` block.
2026-02-17 10:25:31 -08:00
Kristiyan Kostadinov
81cabc1477 feat(core): add support for TypeScript 6
Updates the project to support TypeScript 6 and accounts for some of the breakages.
2026-02-17 08:40:38 -08:00
Matthieu Riegler
5f6088da3a refactor(language-service): split tests into multiple targets
The helps with fighting flakiness
2026-02-13 09:42:05 -08:00
Angular Robot
11767cabe4 build: update Jasmine to 6.0.0
Jasmine enables `forbidDuplicateNames: true` by default. So we also need to desambiguate duplicate spec names.
2026-02-09 12:15:57 -08:00
Charles Lyding
108252bf67 refactor(language-service): use type-only TypeScript imports in some files
Standardize on `import type ts from 'typescript'` across several files
in the language-service package.

This ensures that these files do not have a runtime dependency on a
specific version of the TypeScript module, instead relying on the
instance provided by the host during initialization.

Note: This change is not comprehensive. Several files still require
runtime access to the TypeScript module and will require further
refactoring to fully decouple the dependency.
2026-02-06 07:38:48 -08:00
kbrilla
8c21866f49 feat(language-service): add linked editing ranges for HTML tag synchronization
This feature enables synchronized editing of opening and closing HTML tag pairs
in Angular inline templates. When the cursor is on an element tag name, editing
it will automatically update the corresponding tag.

Implementation:
- Add getLinkedEditingRangeAtPosition method to NgLanguageService interface
- Implement linked editing range detection for opening and closing tags
- Handle edge cases: self-closing elements, void elements, cursor detection
- Export through ts_plugin wrapper to override TypeScript JSX-only implementation
- For external HTML templates, VS Code built-in HTML support handles linked editing
2026-02-04 15:45:27 -08:00
Charles Lyding
03e1a95c26 refactor(language-service): decouple TypeScript dependency in ts_plugin
Update `ts_plugin.ts` to use the TypeScript instance provided by the
editor during initialization instead of a local import. This prevents
potential issues caused by version mismatches between the plugin's
internal TypeScript dependency and the version used by the host.
2026-02-04 15:44:00 -08:00
Charles Lyding
1fa7879cfd refactor(language-service): delegate plugin initialization to bundle
Updates the plugin factory to directly invoke the 'initialize' function from the
Angular Language Service bundle. This replaces manual proxying and lazy-loading
logic with direct delegation, unifying the instantiation process within the bundle.
2026-02-02 11:07:06 -08:00
Charles Lyding
b327d72ed2 refactor(language-service): initial use of type-only imports and standard server types
This commit converts the typescript import in api.ts to a type-only import
and updates the plugin factory to utilize standard TypeScript server types.
Internal interfaces and specific service types are replaced with general
types to decouple the factory wrapper from internal implementations.
2026-01-29 16:06:17 -08:00
Charles Lyding
f9bcccc2b9 build(language-service): remove local development build script
The standalone build.sh script for the language service is no longer
required as the vscode-ng-language-service repository has been merged
into this monorepo. Local development and testing of the extension
can now be handled via the integrated build system.
2026-01-29 13:16:49 -08:00
Charles Lyding
7bb241f7b6 refactor(language-service): introduce withFallback helper in ts_plugin
This commit refactors the `ts_plugin.ts` implementation to use a new `withFallback` helper function. This helper encapsulates the common logic of delegating requests to either the Angular language service directly (for non-TS files or when `angularOnly` is true) or trying the TypeScript language service first before falling back to the Angular language service.
2026-01-28 19:24:16 +00:00
Andrew Scott
8a7cbd4668 fix(language-service): Detect local project version on creation
This updates the language service to use the detected version of angular
core in the given project on load rather than the minimum detected
version in the workspace
2026-01-26 23:51:31 +00:00
Kristiyan Kostadinov
dbc1452de3 refactor(compiler-cli): remove deprecated signature usage
The signature for `createImportClause` was deprecated in TS 5.9. These changes switch to the non-deprecated one.
2026-01-22 21:02:36 +00:00
Kristiyan Kostadinov
d9c980a958 build: initial test of TypeScript 6
Resolves some initial test failures after updating to TypeScript 6.
2026-01-15 13:41:01 -08:00
Kristiyan Kostadinov
87a422358b refactor(compiler-cli): template type checking support for arrow functions
Updates the template type checker to support arrow functions. The main challenge was getting the current infrastructure not to rewrite references to arrow function parameters.
2026-01-09 10:35:37 -08:00
SkyZeroZx
b2f417585a docs: update angular.io links to angular.dev in comments, TSDoc, and warnings 2026-01-07 14:12:15 -05:00
Matthieu Riegler
640693da8e feat(compiler): Add support for multiple swich cases matching
consecutive `@case` blocks are now supported:

```ts
@switch (case) {
  @case (0)
  @case (1) {
    case 0 or 1
  }
  @case (2) {
    case 2
  }
  @default {
    default
  }
}
```

fixes #14659
2026-01-07 09:23:50 -05:00
Kristiyan Kostadinov
10da2f9029 fix(compiler): better types for a few expression AST nodes
We had `any` types for `LiteralArray.expressions`, `Chain.expressions`, `BindingPipe.args`, `LiteralPrimitive.value` and `LiteralMap.values`. These changes add proper types to them.
2026-01-06 12:16:28 -05:00
Kristiyan Kostadinov
3a26244d61 fix(compiler-cli): fix up spelling of diagnostic
Fixes the spelling for the `component is missing a template` diagnostic and expands it a bit.
2026-01-02 08:27:27 +01:00
Kristiyan Kostadinov
fa7cb4b87a fix(compiler): stop ThisReceiver inheritance from ImplicitReceiver
Back in #39323, I added a new `ThisReceiver` node to represent accesses done through `this` and I ended up making it inherit from `ImplicitReceiver`. The logic was that in most cases accessing through `this` was the same as the implicit access.

Over the years this has proven to not be a great idea, because no other AST nodes do this and one has to keep it in mind whenever dealing with `ImplicitReceiver`.

These changes remove the inheritance and update all of the usage sites accordingly.
2026-01-02 08:21:49 +01:00
Andrew Scott
ce1a4769f9 fix(language-service): Prevent language service from crashing on suggestion diagnostic errors
This prevents the language service from crashing when a
`FatalDiagnosticError` is thrown when retrieving suggestion diagnostics.

fixes #66069
2025-12-17 10:13:11 -08:00
Matthieu Riegler
6270bba056 ci: reformat files
This is after we've slightly changed a rule in #66056
2025-12-16 14:44:19 -08:00
SkyZeroZx
ef45637ca8 docs(language-service): add link to hydration guide in built-in names documentation
Adds link to hydration guide for `hydrate` keyword
2025-12-11 17:06:35 -08:00
Joey Perrott
9ace7d7a0d build: add the ignore all rc files flag when running bazel info
Due to a bug in bazel we need to ignore all of the rc files when running bazel info commands
2025-12-09 13:44:45 -08:00
Andrew Scott
4405725943
fix(language-service): address potential memory leak during project creation
This addresses a potential memory leak in plugin-factory.ts.
The require call inside the create function reloads the entire language
service module for every new project, which is inefficient and could be a cause of the memory leak during branch
switching. This ensures the module is loaded only once and the same
instance is shared across all projects.
2025-11-07 11:57:22 -08:00
Jessica Janiuk
37092d00b7 Revert "refactor(compiler-cli): remove deep imports from compiler-cli (#64732)"
This reverts commit 05938c1054.
2025-11-06 13:09:01 -08:00
Matthieu Riegler
05938c1054 refactor(compiler-cli): remove deep imports from compiler-cli (#64732)
Accessed symbols are grouped into dedicated `private` entries

PR Close #64732
2025-11-06 20:01:26 +00:00
Alan Agius
26fed34e0e
build: format md files
This commit configures prettier to format markdown files.
2025-11-06 10:03:05 -08:00
Alan Agius
461eeda6d9 build: remove unneeded language-service dependency (#64306)
The `@angular/language-service` package was not needed for integration tests or benchmarks. Removing this dependency simplifies the build configuration.

PR Close #64306
2025-10-09 10:00:31 -07:00
Kristiyan Kostadinov
f3207000fd refactor(compiler): parse options parameter on viewport triggers (#64130)
Updates the template parser and AST to capture a second object literal parameter on `viewport` triggers.

PR Close #64130
2025-10-09 05:32:20 -07:00
Alan Agius
858e37cf83 build: update cross-repo angular dependencies (#64255)
See associated pull request for more information.

Closes #64212 as a pr takeover

PR Close #64255
2025-10-07 20:15:46 -04:00
Alan Agius
fc643c9044 build: adopt moduleResolution: "bundler" (#64125)
This commit updates the TypeScript configuration across the project to use `moduleResolution: "bundler"`. This modernizes our module resolution strategy to align with current TypeScript best practices and bundler behaviors.

The following changes are included:
- Updated `tsconfig.json` files to set `moduleResolution` to `"bundler"`.
- Updated the `rules_angular` bazel dependency to a version compatible with these changes.
- Adjusted related test files and golden files to reflect the new module resolution strategy.

PR Close #64125
2025-09-29 14:20:23 -04:00
Kristiyan Kostadinov
f5b50ec20d refactor: clean up explicit standalone flags from tests (#63963)
Since standalone is the default, we can dropn the `standalone: true` flags from our tests.

PR Close #63963
2025-09-22 14:27:34 +00:00
Kristiyan Kostadinov
7fd3db0423 fix(compiler-cli): remove internal syntax-related flags (#63787)
Removes the `_enableBlockSyntax` and `_enableLetSyntax` flags in favor of detecting them based on the Angular version.

PR Close #63787
2025-09-16 16:51:17 +00:00
Kristiyan Kostadinov
0571b335b9 feat(compiler-cli): enable type checking of host bindings by default (#63654)
Type checking of host bindings was added in v20. We're now confident enough in it to enable it by default.

BREAKING CHANGE:
* Previously hidden type issues in host bindings may show up in your builds. Either resolve the type issues or set `"typeCheckHostBindings": false` in the `angularCompilerOptions` section of your tsconfig.

PR Close #63654
2025-09-09 14:34:29 -07:00
Joey Perrott
2fcafb65c5 build: rename defaults2.bzl to defaults.bzl (#63383)
Use defaults.bzl for the common macros

PR Close #63383
2025-08-25 15:45:01 -07:00
Joey Perrott
3df1dccebe refactor: various build and import specificer fixes for strict deps (#63323)
Change direct deps in bazel targets and import specifiers within files to maintain strict deps requirements ahead of enabling strict deps tests in the repo

PR Close #63323
2025-08-22 14:45:00 -07:00
ivanwonder
eeeaadc7e9 fix(language-service): Support to resolve the re-export component. (#62585)
In the context of TypeScript (TS), a re-exported symbol is considered a distinct symbol.
This means that a developer can choose to import either the re-exported symbol or
the original symbol. However, in the context of Angular, the re-exported symbol
is treated as the same component because it uses the same selector.

This pull request will utilize the most recent re-export component file to
resolve the module specifier.

PR Close #62585
2025-08-20 09:39:56 +00:00
Joey Perrott
c35c0c7f2f build: update to bazel 7.6.0 (#63096)
Update to later version of bazel

PR Close #63096
2025-08-14 13:01:30 +02:00