Re-export class as part of a different namespace
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 30/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- typescript
- 领域
- compilers
调研方向
先从 panel.ts、panoramicpanel.ts 和 serieschart.ts 的复现开始,然后阅读相关的 TypeScript issue #4529。调查命名空间导出如何处理类值和类类型,并确定是否应支持所请求的 PanoramicPanel 访问模式;当该行为及其产生的诊断信息得到解决时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
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 小时
- 30 天内合并 PR
- 117
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/TypeScript 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
microsoft/TypeScript#64322 · 2 条评论 · 1 个 reaction · 已指派 2 人 ·
-
Possible Improvement
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/TypeScript#64278 · 1 条评论 · 1 个 reaction ·
-
Docs
难度 2/5 1-3 小时 新手友好度 70/100
microsoft/TypeScript#64118 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 88/100
microsoft/TypeScript#64094 ·
-
Docs
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/TypeScript#63959 · 5 条评论 ·
查看 microsoft/TypeScript 的全部 Issue
相似的 Issue
-
kind/bug
难度 2/5 1-3 小时 新手友好度 88/100
kubernetes-sigs/prow#953 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
caddyserver/caddy#8046 ·
-
难度 2/5 1-3 小时 新手友好度 86/100
-
L1 recommended for recruits
难度 2/5 1-3 小时 新手友好度 88/100
-
area/entangle bug
难度 1/5 1 小时以内 新手友好度 92/100