microsoft / microsoft/TypeScript

jsdoc: escaped property names are not parsed properly

オープン
#54,898 コメント 10 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Experience Enhancement Help Wanted Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

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 \u0020 doesn'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. \u0023 is 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. 😅

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンク先の TypeScript Playground と、プロパティ名内のエスケープされた # を示す JSDoc の例から始めてください。JSDoc の typedef とオブジェクトリテラルがどのように解析され、チェックされるかを追跡してください。例でエラーが発生せず、x5t#S256 が宣言されたプロパティとして認識されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, typescript
領域
compilers
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。