Re-export class as part of a different namespace

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

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

評価

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

調査の方向性

panel.ts、panoramicpanel.ts、serieschart.ts の再現から始め、関連する TypeScript issue #4529 を読んでください。namespace export がクラスの値と型をどのように扱うかを調査し、要求されている PanoramicPanel のアクセスパターンをサポートすべきかどうかを定義してください。動作と、それによって生じる diagnostics が解決されれば完了です。

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

説明

In Discussion Suggestion

This is similar to https://github.com/Microsoft/TypeScript/issues/4529, but that issue was closed before it got any real traction.

Setup:

// panel.ts
export class Panel {
    constructor() {}
}

export namespace Panel {
    export enum GridLineTypeFlags {
        NONE = 0x00
    }

    export enum NormalizationType {
        NONE,
        SEPARATE_AXIS
    }
}
export default Panel;
// panoramicpanel.ts
export class PanoramicPanel {
    constructor() {}
    public toString(): string {
        return 'PanoramicPanel';
    }
}

In the serieschart.ts file I'm trying to export the PanoramicPanel class in the same way as I'm exporting the Panel class and namespace, so both can be accessed in my application code as new SeriesChart.PanoramicPanel() and as a type.

The only way I found to make this work is the following, where using the import export syntax gives an error. Is there a reason why there would be an error?

(And because we have a lot of code which depends on the structure of this module, we unfortunately can not get rid of the namespaces.)

// serieschart.ts
import { Panel as PanelType } from './panel';
import { PanoramicPanel as PanoramicPanelType} from './panoramicpanel';

class SeriesChart {

}

namespace SeriesChart {
    export import Panel = PanelType;

    // export import PanoramicPanel = PanoramicPanelType; <- Error: PanoramicPanelType only refers to a type but is used as a namespace here
    // export { PanoramicPanelType as PanoramicPanel} <- Error: Export declarations are not permitted in namespace

    // this works, but is very counter intuitive
    export type PanoramicPanel = PanoramicPanelType;
    export const PanoramicPanel = PanoramicPanelType;
}
export default SeriesChart;
主要言語
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 を短くまとめたダイジェスト。