microsoft / microsoft/TypeScript
Support Closure Compiler-style @typedef
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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.
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
Non sono indicati file di implementazione, test o punti di ingresso. Inizia tracciando il modo in cui TypeScript gestisce le dichiarazioni JSDoc con @typedef in stile Closure, quindi confronta la forma denominata esistente con la forma basata su variabili proposta; il lavoro è completato quando l’esempio crea il simbolo di tipo richiesto senza modificare il JavaScript emesso.
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
- Specificata chiaramente
- Idoneità per principianti
- 35/100