LSP: add configurable checker-backed inlay hints in full mode
- Dominant language
- C#
- Stars
- 154
- Forks
- 4
- Avg merge
- 2h 46m
- Merged PRs (30d)
- 189
Description
Parent epic: #1390. Depends on the required span coverage from #1391. Deferred from #1306.
## Goal
Provide useful, configurable inlay hints from SharpTS's checker in standalone `full` mode without duplicating VS Code/`tsserver` behavior in `interop-only` mode.
## Initial scope
- inferred type hints for unannotated variables, properties, parameters when actually inferred, and function return types;
- parameter-name hints at call/new sites where the selected signature is known and the hint improves readability;
- SharpTS/.NET interop calls use the same resolved overload/signature truth as hover and signature help.
The implementation should ship useful subsets independently through settings, but it must not emit misleading `any` hints merely because analysis was incomplete.
## Work
- [ ] Define initialization/configuration options and defaults for variable/property type, parameter type, return type, and call-site parameter-name hints.
- [ ] Add `textDocument/inlayHint` registration in `full` mode only; decide and test whether configuration changes are live or restart-bound.
- [ ] Map versioned checker `TypeMap` and resolved call signatures to exact insertion positions supplied by #1391.
- [ ] Add a stable, source-valid TypeScript type printer for displayed inferred types, with truncation for excessively large structural/union types.
- [ ] Define suppression rules for explicit annotations, obvious literal identity, `any`/unknown caused by failed analysis, rest parameters, overload ambiguity, and redundant parameter names.
- [ ] Handle generics, contextual typing, destructuring, async/generator returns, optional/rest parameters, JSX calls, decorators, imports, and CLR overloads.
- [ ] Respect requested LSP ranges, document snapshots, cancellation, and cached analysis; do not re-check the workspace once per hint.
- [ ] Define hint padding, label parts, optional tooltip/location behavior, and whether `inlayHint/resolve` is needed.
- [ ] Document client configuration for Neovim and Helix and the intentional absence from `interop-only`.
## Verification
- [ ] Exact-position tests cover ASCII and Unicode, multiline calls, nested expressions, comments, TSX, and malformed/recovered syntax.
- [ ] Type-hint tests cover primitives, literals/widening, unions/intersections, generics, aliases, object/tuple/array types, async/generator functions, destructuring, and imported types.
- [ ] Parameter-name tests cover overload selection, generic inference, optional/rest parameters, callbacks, constructors, methods, and SharpTS CLR interop signatures.
- [ ] Suppression tests prove explicit annotations, ambiguous overloads, analysis failures, and configured-off categories produce no hints.
- [ ] Range, stale-version, cancellation, rapid-edit, and cache-reuse tests are green.
- [ ] Real initialize handshakes advertise inlay hints only in `full`; `interop-only` remains unchanged.
- [ ] End-to-end client-shaped JSON-RPC snapshots verify deterministic ordering and labels.
- [ ] Record latency and allocation counts for a hint request over a representative large file; no per-hint whole-project analysis.
- [ ] Full unit, language-server pack, extension compile, Test262, and TypeScript conformance validation is green.
## Success criteria
Hints are semantically correct, precisely positioned, configurable by category, cheap enough for live editing, resilient to incomplete source, and isolated to standalone `full` mode.
## Non-goals
- Replacing TypeScript inlay hints in VS Code.
- Showing every possible inferred type regardless of usefulness.
- Embedding a second type inference engine in the language server.
Contributor guide
Research direction
Start at the full-mode textDocument/inlayHint registration and the checker TypeMap and resolved-call-signature paths; the issue names no specific files. Use the listed exact-position, type-hint, suppression, range, cancellation, and handshake tests as the verification map. Done means configurable, correctly positioned hints in full mode without hints in interop-only, with the stated validation and performance checks passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, typescript
- Domain
- compilers, developer-experience, devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100