microsoft / microsoft/TypeScript
IntelliSense for generic Promise function shows truncated return type
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TS Template added by @mjbvz
TypeScript Version: 4.0.0-dev.20200702
Search Terms
- hover / quick info
- truncation
- VSCode Version: 1.46.1 (user setup)
- OS Version: Windows_NT x64 10.0.18363
Steps to Reproduce:
App.ts:
import { Repro} from "./Repro";
function test()
{
Repro.repro<number>("test");
}
Repro.ts:
export namespace Repro
{
export interface Arg { argName: string, argValue: any }
// export async function repro<T>(AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijkl: string, ...methodArgs: Arg[]): Promise<T> // Working
export async function repro<T>(AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklX: string, ...methodArgs: Arg[]): Promise<T> // Broken
{
return (new Promise<T>(null));
}
}
Problem:
In App.ts, hover over the .repro function. The IntelliSense shows repro as having a return type of Promise<...>. This is incorrect: it should be Promise<number>.
Now, in Repro.ts edit the repro function by remove the trailing X in the first parameter name. Return to App.ts and note that the IntelliSense for repro is now correct (the function return type is shown as Promise<number>).
While at first glance this may appear to be an edge case due to the long identifier name, it is not. I ran into this problem with "normal length" parameters, but the example above was the simplest repro I could find. Here's the signature of the function where I originally saw the problem:
export async function postForkAsync<T>(destinationInstance: string, methodName: string, methodVersion: number, errorTemplate: string = null, resultTimeoutInMs: number = -1, ...methodArgs: PostMethodArg[]): Promise<T>
Does this issue occur when all extensions are disabled?: Yes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the hover behavior using App.ts and Repro.ts, including the long generic function parameter and the version with the trailing X. Trace the IntelliSense return-type display to determine why it shows Promise<...> instead of Promise; done means the reproduced hover shows the complete generic return type without relying on parameter-name length.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100