microsoft / microsoft/TypeScript

IntelliSense for generic Promise function shows truncated return type

Aperta
#39,517 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il comportamento dell’hover usando App.ts e Repro.ts, incluso il lungo parametro generico della funzione e la versione con la X finale. Segui la visualizzazione del tipo restituito da IntelliSense per determinare perché mostra Promise<...> invece di Promise; l’attività è completata quando l’hover riprodotto mostra il tipo restituito generico completo senza dipendere dalla lunghezza del nome del parametro.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
developer-experience
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.