microsoft / microsoft/TypeScript

No ways to do an alias of an exported type inside a namespace

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

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

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

説明

TypeScript Version: 3.9.7

Search Terms:
export type alias namespace

Code
With import type, in case of long namespaces encapsulation, there's no way to do an alias of the namespaces.
We are forced to alias the final types / interfaces

file types.ts

type A = {}
type B = {}
type C = {}

export type {
    A,
    B,
    C
};

file namespace1.ts

import type * as namespace1 from 'types';

export type {namespace1}

file namespace2.ts

import type * as namespace2 from 'namespace1';

export type {namespace2}

file finalUsage.ts

import type {namespace2} from 'namespace2';

type A = namespace2.namespace1.A; // this is working
namespace aliasNamespaces2 {
   export import namespace1 = namespace2.namespace1; // fails with message 'An import alias cannot reference a declaration that was imported using 'import type'. '
}

Expected behavior:
we need a way to make a shortcut of namespaces2.namespace1

Actual behavior:
Cannot do it: we are forced to aliasthe final types namespaces2.namespace1.A

Playground Link:

Related Issues:

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

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

はじめの一歩

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

調査の方向性

まず、報告された TypeScript 3.9.7 のセットアップで、サンプルファイル types.ts、namespace1.ts、namespace2.ts、finalUsage.ts の動作を再現します。import type aliases と namespace references の処理を追跡し、そのうえで、現在の import-type error を発生させずに namespace2.namespace1 を短縮する、サポートされる方法を定義してテストします。

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

評価

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

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

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