microsoft / microsoft/TypeScript

noImplicitThis codefix should account for static functions

Aperta
#31,964 0 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

Search Terms

codefix static this noImplicitThis

Suggestion

If a function is used as the initializer of a static property declaration, should the type of its this added by the --noImplicitThis codefix include typeof?

See discussion in #31138.

Use Cases

Static methods are arguably more likely to be called with the static class as their this scope in common practice. This would more accurately reflect that behavior.

Examples

const returnThisMember = function ([| |]) {
    return this.member;
}

class Container {
    member = "sample";
    static returnThisMember = returnThisMember;
};

Right now [| |] just becomes this: Container.

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

  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 con il noImplicitThis codefix e la discussione in #31138, quindi segui il modo in cui una funzione usata come inizializzatore di una proprietà statica riceve il proprio tipo this. Usa l'esempio Container per verificare che il tipo suggerito tenga conto dell'ambito statico della classe, incluso typeof dove appropriato.

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

Valutazione

Stack tecnologico
typescript
Ambito
compilers
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.