【问题标题】:Defining TypeScript typing for module gives TS2665?为模块定义 TypeScript 类型会给出 TS2665?
【发布时间】:2016-08-30 03:30:37
【问题描述】:

尝试从旧的 tsd.json 迁移到 typings.json。以前我的.d.ts 有:

declare var modname: modname.modname;

declare module modname {
    export interface modname {
        new (): modname;
    }

    export interface foo {
        bar: string;
    }
}

declare module "mod-name" {
    export = modname;
}

然后由于错误,我将第一行更改为:

declare var modname: modname.modname;

declare namespace modname {

然后得到:

TS2665:模块扩充无法在顶级范围内引入新名称。

也许我打算以不同的方式安装 Typings? - 我注意到奇怪的脚手架被自动添加到我的定义文件中,这些文件是通过以下方式安装的:

typings install github:user/typ/mod-name/mod-name.d.ts --save

【问题讨论】:

    标签: syntax typescript tsc typescript1.8 tsd


    【解决方案1】:

    TS2665:模块扩充无法在顶级范围内引入新名称。

    这不再是最新的Master 版本的打字稿npm install typescript@next 中的错误

    出于各种原因考虑使用此版本:https://basarat.gitbooks.io/typescript/content/docs/getting-started.html#nightly-typescript

    【讨论】:

    • 谢谢,现在尝试使用@next。结果:还原语法并从export = modname; 行获得TS2666: Exports and export assignments are not permitted in module augmentations.
    猜你喜欢
    • 2017-02-17
    • 1970-01-01
    • 2017-03-06
    • 2021-10-27
    • 2017-02-10
    • 2017-07-12
    • 2017-11-05
    • 2016-09-10
    • 1970-01-01
    相关资源
    最近更新 更多