【发布时间】:2018-07-22 02:54:30
【问题描述】:
我正在尝试将 Vanilla Tilt 添加到我的 TypeScript 项目中。我已经安装了它和@types/vanilla-tilt
类型有:
export namespace VanillaTilt {
...
}
export default class VanillaTilt {
static init(...)
}
在我的代码中,我正在做import ... from 'vanilla-tilt'; 的变体。我正在尝试使用VanillaTilt.init。
如果不执行(VanillaTilt as any).init 之类的操作,我无法找到一种方法。
// misnamed import. Import should be named `vanillaTilt` but found `VanillaTilt`
import VanillaTilt from 'vanilla-tilt';
// Property 'init' does not exist on typeof node_modules/@types/vanilla-tilt/index
import vanillaTilt from 'vanilla-tilt';
import { default as VanillaTilt } from 'vanilla-tilt';
// TypeScript does not throw an error, but I get `cannot read property init of undefined`.
import { VanillaTilt } from 'vanilla-tilt';
类型定义有什么问题可以正确导入吗?
【问题讨论】:
标签: typescript definitelytyped