microsoft / microsoft/TypeScript
Better handling for manually created source files and compiler APIs
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Search Terms
type checker source file cannot ready property 'members' of undefined
Suggestion
When a user of the compiler API manually creates a source file with ts.createSourceFile instead of retrieving it from their program, and then asks the program for type inference on a contained node, this can crash. See https://github.com/Microsoft/TypeScript/issues/8136 / https://github.com/vuejs/vue-cli/issues/2712 / https://github.com/angular/tsickle/issues/151 / https://github.com/general-language-syntax/TS-GLS/issues/39.
It seems like one of three interpretations might be best:
- This is explicitly unsupported behavior, but for the sake of performance & simplicity, no checks should happen
- This is explicitly unsupported behavior, and a more explicit error should be thrown
- This should become supported behavior, and the program should dynamically create source files as requested
Use Cases
Auto-generated TypeScript files, such as .vue snippets, still want access to a type checker, such as for TSLint rules.
Examples
https://github.com/palantir/tslint/issues/4273
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. new expression-level syntax)
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 damit, den Absturz mit ts.createSourceFile und einer Abfrage des Typprüfers des Programms zu reproduzieren, die auf einem Knoten der manuell erstellten Datei ausgeführt wird. Prüfe die verknüpften Issues und ermittle, ob dieses Verhalten nicht unterstützt werden, explizit fehlschlagen oder dynamisch unterstützt werden sollte. Als erledigt gilt die Aufgabe, wenn ein festgelegtes API-Verhalten sowie die entsprechende Implementierung und Validierung vorhanden sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100