【发布时间】:2017-11-24 07:56:48
【问题描述】:
我在这里尝试从包类型扩展命名空间@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”上不存在属性“views”.../node_modules/@types/ 完整日历/索引"'。
这应该如何以正确的方式完成?
考虑到types 目录是在typeRoots 中指定的,这里可以避免reference 指令吗?
该应用程序与 Webpack 和 awesome-typescript-loader 捆绑在一起,因此其行为可能与其他编译方法不同。在某些时候类型在 IDE 检查 (WebStorm) 中似乎没问题,但在编译时仍然出现类型错误。
【问题讨论】: