microsoft / microsoft/TypeScript
JSDoc '@this' not actually used to enforce thisArg at callsite
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Bug Report
🔎 Search Terms
JSDoc this
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
@this
⏯ Playground Link
Playground Link: Provided
💻 Code
/** @this {string} */
export function firstCharOfThis() {
return this.charAt(0);
}
firstCharOfThis(); // invalid
firstCharOfThis.call(1); // invalid
firstCharOfThis.call('foo'); // valid
🙁 Actual behavior
No compile error, but a runtime error.
🙂 Expected behavior
First two calls should be an error, last call should be fine. Expected the same behavior as if it was written in TS with an explicit this-parameter
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 con la riproduzione fornita in TypeScript Playground e confronta la funzione JSDoc @this con una dichiarazione equivalente di parametro this esplicito. La correzione è completa quando le chiamate a firstCharOfThis() e firstCharOfThis.call(1) producono errori, mentre firstCharOfThis.call('foo') rimane valido.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 38/100