microsoft / microsoft/TypeScript
jsdoc: escaped property names are not parsed properly
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
Bug Report
🔎 Search Terms
jsdoc
escape
property names
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
jsdoc
⏯ Playground Link
Playground link with relevant code
💻 Code
/**
* @see https://datatracker.ietf.org/doc/html/rfc7517#section-4
* @typedef {Object} JWK
* @prop {string} kty key type
* @prop {string} [x5t\u0023S256] X.509 Certificate SHA-256 Thumbprint
*/
/** @type {JWK} */
const o = {
kty: 'foo',
'x5t#S256': 'bar',
};
🙁 Actual behavior
Errors:
]' expected.
Type '{ kty: string; 'x5t#256': string; }' is not assignable to type 'JWK'.
Object literal may only specify known properties, and ''x5t#256'' does not exist in type 'JWK'.
🙂 Expected behavior
No errors and to parse escaped property names correctly.
Additional Info
If
\u0020doesn't work on VSCode, file it as an issue with them. The way JSDoc works is to allow such escaping.
And that approach should indeed work with any character as "0020" is the hexadecimal Unicode escape sequence for a space.
\u0023is the code for#(familiarize yourself with Unicode escapes in JavaScript to find for others).
Originally posted by @brettz9 in https://github.com/jsdoc/jsdoc/issues/1468#issuecomment-743490820
Edit: Fixed typo in property name. Incidentally shows the importance of types. 😅
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
Commencez par le TypeScript Playground lié et l’exemple JSDoc montrant un # échappé dans un nom de propriété. Suivez la façon dont le typedef JSDoc et le littéral d’objet sont analysés et vérifiés ; le travail est terminé lorsque l’exemple ne produit aucune erreur et reconnaît x5t#S256 comme la propriété déclarée.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, typescript
- Domaine
- compilers
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 42/100