我在这里试图扩展包装类型的命名空间,@typings/fullcalendar
。从包装类型扩展命名空间
/// <reference path="./types/fullcalendar" />
import * as fullcalendar from 'fullcalendar';
import { TimeGrid } from 'fullcalendar';
// TimeGrid and fullcalendar.views are used then
可以看到原件类型here。
而且fullcalendar-custom.d.ts是
import * as FC from 'fullcalendar';
export as namespace FC;
declare class TimeGrid { prepareHits() }
declare let views: any;
这导致类型错误,所以很明显,fullcalendar
命名空间是不正确扩展:
TS2305:模块“” .../node_modules/@ types/fullcalendar/index“'没有导出成员'TimeGrid'。
TS2339:类型'typeof“.../node_modules/@ types/ fullcalendar/index”'上不存在属性'views'。
这应该怎么做才是正确的?
在这里可以避免使用reference
指令,考虑到types
目录在typeRoots
中指定?
该应用程序与Webpack和awesome-typescript-loader捆绑在一起,因此其行为可能与其他编译方法不同。在某些时候IDE的检测类型(WebStorm)类型似乎没有问题,但编译时仍然出现类型错误。
谢谢,我尽量避免再次出口,因为我没有在延长打字的地方延长包裹,但它完成了工作。我结束了'声明类免费...出口默认 origFC; '。 TS的名称空间可以正常使用,但会导致IDE出现一些类型问题。 –
estus