Javascript 无法将自定义.d.ts文件中的枚举添加到模块中
我过去常常将自定义接口/类型添加到我的xxx.d.ts中,以扩展/创建公共模块的新类型。它总是有效的!但是,我发现它不适用于enum 我将以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 {
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”
。似乎我的贴花模块
覆盖了原始的瞬间
键入定义文件
有人能帮我吗?提前谢谢。请在这里查看-