microsoft / microsoft/TypeScript

Non-exported recursive type alias is inlined until it falls back to any in declarations

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

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

Bug Domain: Declaration Emit Help Wanted
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

🔎 Search Terms

declarations recursive types

🕗 Version & Regression Information
  • This is the behavior in every version I tried (before 4.4 it was either a stack overflow crash or an error on the recursive type)
⏯ Playground Link

Playground Link

💻 Code
// @declaration: true
// @filename: utils.ts 

type Recursive<T>  =  T extends Array<infer V>? Recursive<V>: T;

export const f = <T>(): Recursive<T> => { return null! } 

// @filename: index.ts 
import { f } from './utils';
export const a = f;

🙁 Actual behavior

In declarations, the type for a is printed as a: () => T extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? any : V : V : V : V : V : V : V : V : V : V : T;

🙂 Expected behavior

Recursive can't be represented without falling back to any (as seen above) so it should just be an error instead of silently to any

Additional information about the issue

Related to #55832

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

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

はじめの一歩

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

調査の方向性

utils.ts と index.ts を使用して Playground リンクの宣言出力を再現し、エクスポートされたジェネリック関数と a の宣言に焦点を当てます。宣言が出力される際に、エクスポートされていない Recursive エイリアスがどのように表現されるかを追跡します。このケースが、any にフォールバックする深く展開された型を黙って生成するのではなく、エラーを報告すれば完了です。

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

評価

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

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

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