Commit graph

36 commits

Author SHA1 Message Date
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
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
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
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
cbc258eec8 build: remove ts_project_interop infrastructure (#62908)
Remove the interop macros and final usages

PR Close #62908
2025-07-31 09:12:58 +00:00
Joey Perrott
8bf97d1370 build: remove all usages of the interop_deps attr for ts_project and ng_project (#62732)
Remove all of the usages of interop_deps as attributes in the repo

PR Close #62732
2025-07-21 13:03:09 -04:00
ivanwonder
d64dd27a02 feat(language-service): support to report the deprecated API in the template (#62054)
In the Typescript Language Service, these diagnostics are reported as suggestion diagnostics.
This will report the deprecated `Component`, `Directive`, etc.

Fixes https://github.com/angular/angular/issues/59343

PR Close #62054
2025-07-14 15:44:24 -07:00
Jannik Lassahn
20c1f991e6 feat(language-service): add semantic tokens for templates (#60260)
Adds support for `getEncodedSemanticClassifications` to the language service.
The service now classifies components in a template as the `class` type.

PR Close #60260
2025-06-24 16:27:46 +00:00
ivanwonder
cf55d1bdd4 feat(language-service): Support importing the external module's export about the angular metadata. (#61122)
This works for the code actions and completion. When the ls wants to complete
all importable angular metadata in the template, the ls will invoke the function
`ls.getCompletionsAtPosition` and filter the item about the angular. When the
developer selects an item, the ls will get the module specifier from the code action
return by the `ls.getCompletionEntryDetails`.

PR Close #61122
2025-06-04 14:11:20 -04:00
Joey Perrott
b37fd9753f build: migrate language service to use rules_js (#61568)
Migrate language service to build using ts_project

PR Close #61568
2025-05-21 17:05:14 +00:00
Kristiyan Kostadinov
cec512fdfd refactor(language-service): support definitions for selectorless (#61240)
Updates the language service to handle producing definition information for selectorless components and directives.

PR Close #61240
2025-05-12 15:31:45 -07:00
Paul Gschwendtner
e0ff321433 build: prepare testing infrastructure for code splitting of core package (#60487)
When we switch to relative imports, shared `.d.ts` chunks can be
generated.

We need to also pull these into our mock virtual FS testing
environments. Notably this does not cause a test slow-down because we
are talking about very few extra `.d.ts` chunk files. In our experiments
before, with no dts bundling, we saw test time increase from e.g.
20seconds to 100seconds. The 20s are still the same locally!

In addition, since code for definitions can now reside in shared `.d.ts`
chunks, the language service tests need to be adjusted in cases where
they assert for code definition locations in `@angular/core`. A new
helper prepares for more code to be moved into arbitrary `.d.ts` files;
we should simply assert the definition comes out of
`node_modules/@angular/core`.

PR Close #60487
2025-03-20 12:30:57 -07:00
Kristiyan Kostadinov
bf2b0253bc refactor(compiler-cli): move typeCheckHostBindings option (#60267)
Moves the `typeCheckHostBindings` option into `StrictTemplateOptions` and renames the latter.

PR Close #60267
2025-03-17 14:28:41 +01:00
Paul Gschwendtner
5c4305f024 feat(language-service): support migrating full classes to signal inputs in VSCode (#57975)
This commit expands the VScode integration of the signal input migration
to allow migration of full classes and all their inputs. This enables a
faster workflow than just migrating every member individually.

In addition, we now properly support migrating classes that are
unexported and no actual metadata is available in `ngtsc` (but this is
fine for the migration).

PR Close #57975
2024-09-30 13:29:21 -07:00
Joey Perrott
9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00
Paul Gschwendtner
1f067f4507 feat(language-service): add code reactoring action to migrate @Input to signal-input (#57214)
(experimental at this point)

Language service refactoring action that can convert `@Input()`
declarations to signal inputs.

The user can click on an `@Input` property declaration in e.g. the VSCode
extension and ask for the input to be migrated. All references, imports and
the declaration are updated automatically.

PR Close #57214
2024-08-29 07:50:41 -07:00
Kristiyan Kostadinov
e5a6f91722 feat(core): support TypeScript 5.5 (#56096)
Updates the repo to add support for TypeScript 5.5. Includes resolving some compilation errors and broken tests.

PR Close #56096
2024-05-29 15:33:33 +02:00
Joey Perrott
ca517d7f2c refactor: migrate language-service to prettier formatting (#55405)
Migrate formatting to prettier for language-service from clang-format

PR Close #55405
2024-04-18 14:18:38 -07:00
Dylan Hunn
ef39107ce5 refactor(language-service): Replace tsserverlibrary -> typescript (#54726)
Typescript recently consolidated `tsserverlibrary` into `typescript`: [blog post](https://devblogs.microsoft.com/typescript/announcing-typescript-5-3/#consolidation-between-tsserverlibrary-js-and-typescript-js)

In this commit, we remove all references to `tsserverlibrary` accordingly. This should be safe, since v18 and later support TS 5.3+.

PR Close #54726
2024-03-07 10:49:01 -08:00
Paul Gschwendtner
2df8584619 refactor(compiler-cli): speed up compiler tests by caching Angular (#54650)
Currently the `makeProgram` utility from `ngtsc/testing` does not use
the test host by default- optimizing for source file caching.

Additionally, the host can be updated to attempt caching of the `.d.ts`
files from `@angular/core`— whether that's fake core, or the real core-
is irrelevant. We are never caching if these changes between tests, so
correctness is guaranteed.

This commit reduces the type check test times form 80s to just 11
seconds, faster than what it was before with `fake_core`. The ngtsc
tests also run significantly faster. From 40s to 30s

PR Close #54650
2024-03-06 12:34:39 +01:00
Paul Gschwendtner
400b739874 test: add language-service tests for outputFromObservable() (#54650)
Adds additional language-service tests for `outputFromObservable()`.
Existing tests already verify the behavior for `output()`.

PR Close #54650
2024-03-06 12:34:39 +01:00
Paul Gschwendtner
2564b45b47 test: replace fake_core with real @angular/core output (#54650)
This commit replaces `fake_core` with the real `@angular/core`
output. See previous commit for reasons.

Overall, this commit:

* Replaces references of `fake_core`
* Fixes tests that were testing Angular compiler detection that _would_
  already be flagged by type-checking of TS directly. We keep these
  tests for now, and add `@ts-ignore` to verify the Angular checks, in
  case type checking is disabled in user applications- but it's worth
  considering to remove these tests. Follow-up question/non-priority.
* Adds `@ts-ignore` to the tests for `defer` 1P because the property is
  marked as `@internal` and now is (correctly) causing failures in the
  compiler test environment.
* Fixes a couple of tests with typos, wrong properties etc that
  previously weren't detected! A good sign.

PR Close #54650
2024-03-06 12:34:38 +01:00
Andrew Scott
023a181ba5 feat(language-service): Implement outlining spans for control flow blocks (#52062)
This commit implements the getOutlingSpans to retrieve Angular-specific
outlining spans. At the moment, these spans are limited to control-flow
blocks in templates.

This is required for folding ranges (https://github.com/angular/vscode-ng-language-service/issues/1930)

PR Close #52062
2023-10-09 10:20:26 -07:00
Kristiyan Kostadinov
9cc52b9b85 feat(core): support TypeScript 5.2 (#51334)
Updates the project to support TypeScript 5.2.

PR Close #51334
2023-08-18 07:55:16 -07:00
Andrew Scott
ce00738f98 fix(compiler-cli): catch fatal diagnostic when getting diagnostics for components (#50046)
This commit adds similar handling to what was done in ed817e32fe.
The language service calls the `getDiagnosticsForComponent` function
when the file is not a typescript file.

fixes https://github.com/angular/vscode-ng-language-service/issues/1881

PR Close #50046
2023-04-28 15:18:03 +02:00
Kristiyan Kostadinov
99d874fe3b feat(core): add support for TypeScript 5.0 (#49126)
Updates the project to support TypeScript 5.0 and to resolve any errors that came up as a result of the update.

PR Close #49126
2023-02-28 08:24:47 -08:00
Paul Gschwendtner
acf98268f8 refactor: update language-service package and tests to work with ESM (#48521)
The Angular Language Service package is now tested & compiled using ESM.
Previously it was a mismatch of CommonJS and ESM.

Still the language-service ESM output is transformed into a single UMD
bundle to allow for module resolution to be overriden. See
`bundles/BUILD`.

This is kept as is. To fully ship ESM (language-service is an exception
here), we need to:

 * Update all code to no longer reference typescript via import. Instead
   typescript needs to be passed around so that the extension can
   control the version
 * The VSCode extension/ the TS server needs to be able to load ESM. It
   looks like the server supports ESM global plugins, but the extension
   might not yet.

This is out of scope for the dev-infra effort as it requires more
insight into VSCode & the extension system & the TS language server.

PR Close #48521
2022-12-19 19:50:44 +00:00
Dylan Hunn
bebef5fb43 feat(language-service): Quick fix to import a component when its selector is used (#47088)
The language service can now generate an import corresponding to a selector. This includes both the TypeScript module import and the decorator import. This applies to both standalone components and components declared in NgModules.

PR Close #47088
2022-10-10 21:32:43 +00:00
ivanwonder
598b72bd05 feat(language-service): support fix the component missing member (#46764)
The diagnostic of the component missing member comes from the ts service,
so the all code fixes for it are delegated to the ts service.

The code fixes are placed in the LS package because only LS can benefit from
it now, and The LS knows how to provide code fixes by the diagnostic and NgCompiler.

The class `CodeFixes` is useful to extend the code fixes if LS needs to
provide more code fixes for the template in the future. The ts service uses
the same way to provide code fixes.

1622247636/src/services/codeFixProvider.ts (L22)

Fixes https://github.com/angular/vscode-ng-language-service/issues/1610

PR Close #46764
2022-08-02 11:58:21 -07:00
JoostK
93d17ee888 fix(compiler-cli): only consider used pipes for inline type-check requirement (#46807)
After a bugfix in #46096, the compiler is now better capable of detecting pipes
which require an inline type constructor. However, there is an issue in how all
pipes are considered when verifying the inline type-ctor requirement: it should
only check actually used pipes.

Fixes #46747

PR Close #46807
2022-07-12 21:09:18 +00:00
Andrew Scott
d48cfbca75 fix(language-service): Add resource files as roots to their associated projects (#45601)
When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a `tsconfig` cannot express including non-TS files,
we need another way to indicate the template files are considered part of the project.

Note that this does not ensure that the project in question _directly_ contains the component
file. That is, the project might just include the component file through the program rather
than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important
because the TypeScript language service/server prefers projects which _directly_ contain the TS
file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can
possibly be a different project used between the TS and HTML files.

For example, in Nx projects, the referenced configs are `tsconfig.app.json` and
`tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and
contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS
files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files
but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot
effectively express `projectContainsInfoDirectly` for HTML files.

We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal `project.projectContainsInfoDirectly`
or as a workaround, check `project.isRoot(componentTsFile)`.

Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not
`tsconfig.app.json`. However, if our extension does not also know to select
`tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined
first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in
keeping projects open when there is an HTML file open and (2) optionally attempt to do this
_only_ for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close)
and prioritize that project for all requests.

fixes https://github.com/angular/vscode-ng-language-service/issues/1623
fixes https://github.com/angular/vscode-ng-language-service/issues/876

PR Close #45601
2022-05-10 09:36:26 -07:00
Kristiyan Kostadinov
29039fcdbc feat(core): support TypeScript 4.7 (#45749)
Adds support for TypeScript 4.7. Changes include:
* Bumping the TS version as well as some Bazel dependencies to include https://github.com/bazelbuild/rules_nodejs/pull/3420.
* Adding a backwards-compatibility layer for calls to `updateTypeParameterDeclaration`.
* Making `LView` generic in order to make it easier to type the context based on the usage. Currently the context can be 4 different types which coupled with stricter type checking would required a lot of extra casting all over `core`.
* Fixing a bunch of miscellaneous type errors.
* Removing assertions of `ReferenceEntry.isDefinition` in a few of the language service tests. The field isn't returned by TS anymore and we weren't using it for anything.
* Resolving in error in the language service that was caused by TS attempting to parse HTML files when we try to open them. Previous TS was silently setting them as `ScriptKind.Unknown` and ignoring the errors, but now it throws. I've worked around it by setting them as `ScriptKind.JSX`.

PR Close #45749
2022-04-29 12:19:45 -04:00
Tobias Speicher
4ddcf81e61 refactor: replace deprecated String.prototype.substr() (#45397)
.substr() is deprecated so we replace it with functions which work similarily but aren't deprecated

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>

PR Close #45397
2022-03-24 11:48:09 -07:00
Alex Rickabaugh
8c71b9fc42 refactor: delete the View Engine runtime (#43884)
This commit removes the View Engine runtime. Itself, this change is
relatively straightforward, but it represents the final step in a multi-year
journey. It's only possible due to the hard work of many current and former
team members and collaborators, who are too numerous to list here.

Co-authored-by: Alan Agius <alan.agius4@gmail.com>
Co-authored-by: Andrew Kushnir <akushnir@google.com>
Co-authored-by: Andrew Scott <atscott01@gmail.com>
Co-authored-by: Andrew Seguin <andrewjs@google.com>
Co-authored-by: Cédric Exbrayat <cedric@ninja-squad.com>
Co-authored-by: Charles Lyding <19598772+clydin@users.noreply.github.com>
Co-authored-by: Dave Shevitz <dshevitz@google.com>
Co-authored-by: Doug Parker <dgp1130@users.noreply.github.com>
Co-authored-by: Dylan Hunn <dylhunn@gmail.com>
Co-authored-by: Emma Twersky <emmatwersky@google.com>
Co-authored-by: George Kalpakas <kalpakas.g@gmail.com>
Co-authored-by: Igor Minar <iminar@google.com>
Co-authored-by: Jeremy Elbourn <jelbourn@google.com>
Co-authored-by: Jessica Janiuk <jessicajaniuk@google.com>
Co-authored-by: JiaLiPassion <JiaLi.Passion@gmail.com>
Co-authored-by: Joey Perrott <josephperrott@gmail.com>
Co-authored-by: Joost Koehoorn <joost.koehoorn@gmail.com>
Co-authored-by: Kristiyan Kostadinov <crisbeto@abv.bg>
Co-authored-by: Madleina Scheidegger <mscheid@google.com>
Co-authored-by: Mark Thompson <2554588+MarkTechson@users.noreply.github.com>
Co-authored-by: Minko Gechev <mgechev@gmail.com>
Co-authored-by: Paul Gschwendtner <paulgschwendtner@gmail.com>
Co-authored-by: Pawel Kozlowski <pkozlowski.opensource@gmail.com>
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
Co-authored-by: Wagner Maciel <wagnermaciel@google.com>
Co-authored-by: Zach Arend <zachzach@google.com>

PR Close #43884
2021-11-23 21:10:06 +00:00
Andrew Scott
670cd10e30 refactor(language-service): Move language service code out of ivy/ folder (#44064)
This commit moves code in the language service package out of the ivy
subfolder. Ivy is the _only_ engine supported in v13+ so there's no need
to have a name for it.

PR Close #44064
2021-11-10 01:20:04 +00:00