feat(lsp): add inferred type request#35099
Open
divybot wants to merge 4 commits into
Open
Conversation
…ties TypeScript's "Infer function return type" refactor already executes through the LSP, but its code action kind was not in ALL_KNOWN_REFACTOR_ACTION_KINDS so the kind was never advertised in the server's InitializeResult. Clients like vscode use that list to populate the "Refactor..." menu; without the kind they cannot surface the action via the standard refactor UI. This lets users discover and invoke "Infer function return type" to see and copy the full inferred return type for any function — a workaround for vscode's truncated type peek window. Refs #23901 Closes denoland/divybot#425 Co-Authored-By: Divy Srivastava <me@littledivy.com>
Co-Authored-By: Divy Srivastava <me@littledivy.com>
Co-Authored-By: Divy Srivastava <me@littledivy.com>
491cefb to
dc440cf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
deno/inferredTypecustom LSP request that returns the full TypeScript QuickInfo display string and source range for the symbol at a text document position. The TypeScript quick-info bridge now passes an explicit largemaximumLength, so hover and inferred-type callers avoid the default truncation.Also advertises a
refactor.extract.inferredTypecode action titled "Copy inferred type". The code action carries the precomputed inferred type text as command data, giving clients a discoverable native entry point for copying full inferred type text while allowing editor extensions to own clipboard access.Companion VS Code extension PR: denoland/vscode_deno#1381
Verification:
cargo build --bin denocargo fmt --checkcargo test -p integration_tests --test integration lsp_inferred_type -- --nocapturecargo build -p test_servercargo test -p integration_tests --test integration lsp_hover -- --nocaptureRefs #23901
Closes denoland/divybot#425