microsoft / microsoft/TypeScript
Inference for Object.isPrototypeOf()
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
Hi, I am wondering would be possible to infer types for isPrototypeOf() function same way as it's done with instanceof operator? So we could narrow type of argument if it's been created using Object.create(proto) function and its type would be something like typeof proto if check is fulfilled.
Search Terms
isPrototypeOf
Examples
if (object instanceof HTMLAnchorElement) {
console.log(object.href);
}
if (HTMLAnchorElement.prototype.isPrototypeOf(object)) {
console.log(object.href);
}
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
Nell’issue non sono identificati alcun file di implementazione, test o punto di ingresso. Inizia individuando il restringimento di tipo esistente per instanceof, quindi valuta come dovrebbero essere ristretti gli oggetti creati con Object.create(proto) negli esempi di Object.isPrototypeOf(); il lavoro è completo quando il comportamento proposto è specificato e coperto da test appropriati del compilatore.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, typescript
- Ambito
- compilers
- 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