microsoft / microsoft/TypeScript
Support Closure Compiler-style @typedef
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.4k
- Merge moyen
- 1 j 19 h
- PR mergées (30 j)
- 117
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Aucun fichier d’implémentation, test ou point d’entrée n’est indiqué. Commencez par suivre la manière dont TypeScript traite les déclarations JSDoc avec @typedef de style Closure, puis comparez la forme nommée existante à la forme basée sur une variable proposée ; c’est terminé lorsque l’exemple crée le symbole de type demandé sans modifier le JavaScript généré.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, typescript
- Domaine
- compilers
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 35/100