microsoft / microsoft/TypeScript
"is not a constructor" should be detected in compile time as "used before its declaration."
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
TypeScript Version: 3.2.2
This repository demonstrates that I run in to the issue in ts@next.
https://github.com/qballer/tsbug
Search Terms:
constructor, lexical scope, run time error vs compile time
Code
const b = getB()
function getB() {
// will throw C is not a constructor in runtime
return new C() // **
}
// Will generate: Class 'C' used before its declaration.
// const instanceOfC = new C()
class C {}
Expected behavior:
Should generate: Class 'C' used before its declaration.
Actual behavior:
Explodes in runtime with 'is not a constructor' error.
Playground Link:
Playground
Repo
Related Issues:
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem Reproduktionscode im verlinkten qballer/tsbug-Repository und dem TypeScript Playground-Beispiel und vergleiche dann die bestehende Diagnose für const instanceOfC = new C() mit dem Fall getB(). Als erledigt gilt die Aufgabe, wenn der Compiler für den Konstruktoraufruf "Class 'C' used before its declaration" meldet, anstatt den Laufzeitfehler "is not a constructor" zuzulassen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100