microsoft / microsoft/TypeScript

Move types from jsdoc quickfix (instead of copy)

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

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

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

説明

Search Terms

  • jsdoc quickfix
  • 80004

Suggestion

There's a great quickfix available to copy JSDoc type annotations to TypeScript annotations:

image

When you do this, however, you still have type annotations in your JSDoc. This is duplicative and is likely to lead to the types getting out of sync over time. It's best to avoid putting type information in JSDoc once you're using TypeScript.

I'd like a quickfix that annotates types and removes the types from the JSDoc.

Use Cases

This would be helpful for any project converting from JavaScript to TypeScript. You should convert your JSDoc types to TypeScript types and you should remove types from your JSDoc once you do. This sort of quickfix would help people get to the right place.

Examples

/**
 * @param a {string} Base string.
 * @param b {string=} Optional string to add
 * @return {string}
 */
function foo(a, b) {
  if (b) return a + b;
  return a;
}

should get converted to:

/**
 * @param a Base string.
 * @param b Optional string to add
 */
function foo(a: string, b?: string): string {
  if (b) return a + b;
  return a;
}

rather than:

/**
 * @param a {string} Base string.
 * @param b {string=} Optional string to add
 * @return {string}
 */
function foo(a: string, b: string | undefined): string {
  if (b) return a + b;
  return a;
}

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • 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.

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

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

はじめの一歩

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

調査の方向性

まず、検索語 80004 に関連付けられた既存の JSDoc quickfix を見つけ、それが JSDoc の型をどのように TypeScript のアノテーションに変換しているかを追跡します。受け入れ条件の目標として例を使用します。型を関数シグネチャに移し、戻り値のアノテーションを含め、JSDoc から型情報を削除します。

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

評価

技術スタック
javascript, typescript
領域
developer-experience, tooling
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

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

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