microsoft / microsoft/TypeScript
Support Closure Compiler-style @typedef
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
- Closure Compiler typedef
Suggestion
With Closure Compiler-style JSDoc, you name an @typedef type definition by introducing a var in the next statement:
/** @typedef {(string|number)} */
var NumberLike;
TypeScript doesn't recognize this construct. Instead, it wants you to write:
/** @typedef {(string|number)} NumberLike */
Use Cases
Migrating code written for use with Google's Closure Compiler over to TypeScript.
Examples
See above. My proposal is that, when prefixed with an @typedef with only a type (and no name), a variable definition would create a symbol in the type namespace in addition to the value namespace.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
→ If the variable has the same name as an existing type, this would create a break. But this would indicate an issue if the two types disagreed. - 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
Es werden keine Implementierungsdateien, Tests oder Einstiegspunkte genannt. Beginne damit nachzuverfolgen, wie TypeScript Closure-artige JSDoc-Deklarationen mit @typedef verarbeitet, und vergleiche dann die bestehende benannte Form mit der vorgeschlagenen variablenbasierten Form; fertig ist es, wenn das Beispiel das angeforderte Typsymbol erstellt, ohne das ausgegebene JavaScript zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 35/100