Allow `infer function return type` refactor when return type are not imported

オープン
#45,040 コメント 1 件 リアクション 3 件 担当者 0 名 GitHub で見る

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
typescript

調査の方向性

まず、返されるオブジェクトがインポートされていない型を使用する関数で、infer function return type リファクタリングを再現します。既存のリファクタリングの動作を確認し、提案されているどの対応が適切かを判断します。不足している型を自動インポートする、不足を報告する、または unknown に置き換える、のいずれかです。不足しているインポートに対するリファクタリングの動作が定義され、動機となったケースをカバーできれば完了です。

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

説明

Awaiting More Feedback Suggestion

Suggestion

🔍 Search Terms

"infer function return type"

refactor

✅ Viability 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, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Infer function treturn type require all types used in return type are imported.
It takes a while to find which field is using a not imported type when returning many values as a object.

I want this refactor allowed by:

a. Auto import missing types
b. Show a message that tell user what is missing
c. Replace not imported type with unknown .

📃 Motivating Example

infer function return type refactor works when there is missing imports

💻 Use Cases

I'm extracting vue code to use composition api, with eslint rule @typescript-eslint/explicit-module-boundary-types enabled.
so i want use this refactor.

But infer function return type is not avaiable because some type not imported.

image

And i can not view all types because there is too many.

image

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

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

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

はじめの一歩

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

microsoft/TypeScript のほかの issue

microsoft/TypeScript の issue をすべて見る

似ている issue

Go の issue をもっと見る

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

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