【发布时间】:2017-06-28 19:40:32
【问题描述】:
我一直在尝试为“react-dates”npm 模块编写自定义声明文件,但无法让编译器将我的声明文件解析为该模块。
当我执行import {DateRangePicker} from 'react-dates' 时,出现以下错误:
找不到模块“react-dates”的声明文件。 'absolute_path/src/node_modules/react-dates/index.js' 隐式具有“任何”类型。
我的声明文件位于路径“@types/react-dates/index.d.ts”中,如下所示:
import * as React from 'react';
declare class DateRangePicker extends React.Component<{}, {}> { }
tsconfig.json 看起来像这样:
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"strictNullChecks": true,
"module": "commonjs",
"target": "es6",
"jsx": "react",
"typeRoots": [
"./@types"
]
},
"include": [
"./app/**/*",
"./@types/**/*"
]
}
【问题讨论】:
-
你自己打字有没有到任何地方?
-
我只使用了库的一小部分,但到目前为止我已经得到了:gist.github.com/torryt/ccdaf6daf0d7df6252ac2a4539a00520
标签: typescript typescript-typings