Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法将自定义.d.ts文件中的枚举添加到模块中_Javascript_Typescript_Typescript Typings - Fatal编程技术网

Javascript 无法将自定义.d.ts文件中的枚举添加到模块中

Javascript 无法将自定义.d.ts文件中的枚举添加到模块中,javascript,typescript,typescript-typings,Javascript,Typescript,Typescript Typings,我过去常常将自定义接口/类型添加到我的xxx.d.ts中,以扩展/创建公共模块的新类型。它总是有效的!但是,我发现它不适用于enum 我将以moment.js为例 对于接口,在我的typings.d.ts中,我有 declare module 'moment' { interface MyInterface { foo: string; } } declare module 'moment' { export enum MyEnum {

我过去常常将自定义接口/类型添加到我的xxx.d.ts中,以扩展/创建公共模块的新类型。它总是有效的!但是,我发现它不适用于enum

我将以
moment.js
为例


对于接口,在我的
typings.d.ts
中,我有

declare module 'moment' {
    interface MyInterface {
        foo: string;
    }
}
declare module 'moment' {
    export enum MyEnum {
        foo = 'bar'
    }
}
在我的index.ts中,我有

import { MyInterface } from 'moment';

let test: MyInterface;
// when I type "test." here, "foo" is suggested for me. Which means it is working.
import { MyEnum, Locale } from 'moment';

对于enum,在我的
typings.d.ts

declare module 'moment' {
    interface MyInterface {
        foo: string;
    }
}
declare module 'moment' {
    export enum MyEnum {
        foo = 'bar'
    }
}
在我的index.ts中,我有

import { MyInterface } from 'moment';

let test: MyInterface;
// when I type "test." here, "foo" is suggested for me. Which means it is working.
import { MyEnum, Locale } from 'moment';
我得到了
TS2305:模块“矩”没有导出成员“Locale”
。似乎我的
贴花模块
覆盖了原始的
瞬间
键入定义文件

有人能帮我吗?提前谢谢。

请在这里查看-