microsoft / microsoft/TypeScript
type destructuring
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
Search Terms
type destructuring
Suggestion
Allow destructuring syntax when assigning type
Use Cases
Dynamically assign a type as the type of an other type's property.
Examples
Where AutocompleteService is a class, PlacesServiceStatus is an enum, and AutocompletePrediction is an interface.
What I'm doing currently:
const { AutocompleteService, PlacesServiceStatus } = google.maps.places;
type AutocompletePrediction = google.maps.places.AutocompletePrediction;
What I'd like to be able to do:
const { AutocompleteService, PlacesServiceStatus } = google.maps.places;
type { AutocompletePrediction } = google.maps.places;
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.
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
Das Issue schlägt vor, Destructuring-Syntax in einer Typzuweisung zuzulassen, und zeigt mit einem TypeScript-Beispiel die gewünschte Form. Es werden keine Implementierungsdateien, Einstiegspunkte oder Tests genannt; beginne damit, nachzuverfolgen, wie TypeScript Typ-Aliase parst und prüft, und definiere anschließend Tests, die gültiges Type-Destructuring von vorhandener Syntax unterscheiden. Als erledigt gilt die Aufgabe, wenn das Beispiel ohne Änderungen am erzeugten JavaScript eine Typprüfung besteht.
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
- Größtenteils klar
- Anfängerfreundlichkeit
- 30/100