首页 > 解决方案 > 命名空间未标记为仅类型声明

问题描述

我有一个看起来像这样的打字稿文件:

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 错误的通天塔。

这个错误“命名空间未标记仅类型声明”令人费解,因为它似乎不是正确的英语。里面应该有逗号吗?

我应该声明什么吗?什么是仅类型命名空间?

标签: typescriptbabeljs

解决方案


推荐阅读