microsoft / microsoft/TypeScript
Add a code action to implement (overwritten) method from base class
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
Search Terms
implement, inherited, method
Suggestion
When implementing a method that is defined in a class's base class or in external type declarations, it would be helpful if we didn't have to type out the method signature that is already known to TypeScript.
Use Cases
Overwriting methods in inherited classes. Here's an example for implementing a custom winston transport.

TypeScript knows the method signature, but I have to type it out manually, potentially making a mistake along the way.
Examples
import * as Transport from "winston-transport";
export class SpyTransport extends Transport {
log| // cursor here!
}
VSCode should offer a code action implement method "log" from base class "Transport". After invoking it, the code should look like this:
import * as Transport from "winston-transport";
export class SpyTransport extends Transport {
public log(info: any, next: () => void): any {
throw new Error("not implemented!");
}
}
For reference, the type declarations look as follows:
declare class TransportStream extends stream.Writable {
public format?: logform.Format;
public level?: string;
public silent?: boolean;
public handleExceptions?: boolean;
constructor(opts?: TransportStream.TransportStreamOptions);
public log?(info: any, next: () => void): any;
public logv?(info: any, next: () => void): any;
public close?(): void;
}
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia individuando il punto di ingresso di code action di TypeScript o VSCode che gestisce i metodi ereditati o non implementati. Usa l’esempio e la dichiarazione di TransportStream dell’issue come riferimento comportamentale e considera il lavoro completo quando una code action propone il metodo ereditato e genera la relativa firma nota e uno stub.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- developer-experience
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100