microsoft / microsoft/TypeScript

Declarations are not generated for a high order component

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

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

Domain: Declaration Emit Experience Enhancement Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

TypeScript Version: 3.2.0-dev.201xxxxx, 2.9.1, 3.1.3

Search Terms:

declaration, high-order, hoc

Code

export function Executor(func: () => any) {
  class ExecutingClass {
    execute() {
      func();
    }
  }

  return ExecutingClass;
}

Expected behavior:

Running both tsc and tsc -d produces no errors.

Actual behavior:

When I'm running tsc on this code, everything works fine.
When I'm running tsc -d on this code, I have this error:

hoc.ts:1:17 - error TS4060: Return type of exported function has or is using private name 'ExecutingClass'.

1 export function Executor(func: () => any) {

It is still possible to generate typings for this if you change code to this:

export function Executor(func: () => any) {
  const ExecutingClass = class {
    execute() {
      func();
    }
  }

  return ExecutingClass;
}

export default Executor;

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

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

はじめの一歩

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

調査の方向性

指定された TypeScript バージョンで tsc と tsc -d の両方を使って例を再現し、その後、匿名クラスのバリアントと動作を比較します。元々エクスポートされている高階コンポーネントが TS4060 なしで宣言を生成すれば、問題は解決です。リポジトリのファイルやテストは指定されていません。

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

評価

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

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

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