microsoft / microsoft/TypeScript
IntelliSense for generic Promise function shows truncated return type
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das Hover-Verhalten mit App.ts und Repro.ts zu reproduzieren, einschließlich des langen generischen Funktionsparameters und der Version mit dem nachgestellten X. Verfolge die Anzeige des IntelliSense-Rückgabetyps, um festzustellen, warum statt Promise Promise<...> angezeigt wird; abgeschlossen ist die Aufgabe, wenn der reproduzierte Hover den vollständigen generischen Rückgabetyp anzeigt, ohne sich auf die Länge des Parameternamens zu stützen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- developer-experience
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 35/100