Quick fix to convert @typedef to type or interface

Aperta
#31,500 2 commenti 7 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, typescript
Ambito
compilers

Direzione di ricerca

La issue non fornisce file del repository, test o punti di ingresso. Inizia esaminando l’architettura dei quick-fix di TypeScript e i codefixes esistenti relativi a JSDoc, quindi determina la conversione prevista per l’esempio @typedef mostrato. Il lavoro è completato quando un quickfix converte i typedefs JSDoc supportati in un type o un interface senza modificare l’output di runtime.

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

Descrizione

Awaiting More Feedback Suggestion

Search Terms

  • typedef quickfix
  • typedef jsdoc

Suggestion

I have lots of code in an old Closure Compiler-style project that looks like this:

/**
 * @typedef {{
 *   px: number,
 *   py: number,
 *   isZooming: boolean,
 *   isPanning: boolean,
 *   is2DPan: boolean,
 *   cancelNextDblclick: boolean,
 *   initializeMouseDown: (e: !Event, dygraph:!DygraphAny, context: !DygraphInteractionContext) => void
 * }} DygraphInteractionContext
 */

If I declare a variable with this type, I can see that TypeScript understands the @typedef:

type DygraphInteractionContext = {
    px: number;
    py: number;
    isZooming: boolean;
    isPanning: boolean;
    is2DPan: boolean;
    cancelNextDblclick: boolean;
    initializeMouseDown: (e: Event, dygraph: any, context: ...) => void;
}

I'd like to convert this to a type or interface. I can introduce a dummy variable, copy the TS-style type declaration and paste it in to do the conversion.

But it'd be easier if there were a quickfix!

Use Cases

Migrating a project that used JSDoc-based typing. A workaround is available, but a quickfix would be a big improvement.

Examples

(see above)

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 15h
PR unite (30g)
106

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.

Altre issue di microsoft/TypeScript

Tutte le issue di microsoft/TypeScript

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.