typescript - 命名空间未标记为仅类型声明
问题描述
我有一个看起来像这样的打字稿文件:
export namespace MyNamespace {
export const myFunc = (a:number) => 3;
}
当我编译它时(在我的例子中,我使用的是故事书),我得到了这个错误:
Namespace not marked type-only declare. Non-declarative namespaces are only supported experimentally in Babel
. To enable and review caveats see: https://babeljs.io/docs/en/babel-plugin-transform-typescript
据我所知,这是一个试图编译 TS 错误的通天塔。
这个错误“命名空间未标记仅类型声明”令人费解,因为它似乎不是正确的英语。里面应该有逗号吗?
我应该声明什么吗?什么是仅类型命名空间?
解决方案
推荐阅读
- database - 卡蒙达数据库。保存 id 而不是对象
- sql - ORA-01417 - 两个外部连接错误。新的连接语法?
- c# - 如何在winforms中打印列或行跨越的datagridview
- javascript - Angular 8 从其上下文之外访问数据并检测更改
- python - 如何通过 python 脚本修改网页浏览历史?
- python - 如何正确连接两个一维数组而不展平?
- php - 插入新图像后如何从上传文件夹中删除旧图像
- typescript - 扩展另一个内部类的 TypeScript 内部类不可分配给超类(声明合并)
- python - 嵌套 if 用于带有模式的变量名
- json - 如何从 OpenAPI 3.0 规范生成 JSON 示例