Typescript 找不到带有';的自定义声明文件的声明文件;反应日期';模块

Typescript 找不到带有';的自定义声明文件的声明文件;反应日期';模块,typescript,typescript-typings,Typescript,Typescript Typings,我一直在尝试为'react dates'npm模块编写自定义声明文件,但无法让编译器将我的声明文件解析为该模块 当我从'react dates'导入{DateRangePicker}时,我得到以下错误: 找不到模块“反应日期”的声明文件。 'absolute_path/src/node_modules/react dates/index.js' 隐式具有“any”类型 我的声明文件位于路径“@types/react dates/index.d.ts”中,如下所示: import * as Rea

我一直在尝试为'react dates'npm模块编写自定义声明文件,但无法让编译器将我的声明文件解析为该模块

当我从'react dates'导入{DateRangePicker}时,我得到以下错误:

找不到模块“反应日期”的声明文件。 'absolute_path/src/node_modules/react dates/index.js' 隐式具有“any”类型

我的声明文件位于路径“@types/react dates/index.d.ts”中,如下所示:

import * as React from 'react';
declare class DateRangePicker extends React.Component<{}, {}> { }
{
  "compilerOptions": {
    "outDir": "./dist/",
    "sourceMap": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "module": "commonjs",
    "target": "es6",
    "jsx": "react",
    "typeRoots": [
      "./@types"
    ]
  },
  "include": [
    "./app/**/*",
    "./@types/**/*"
  ]
}
declare module 'react-dates' {
  import { Component } from 'react';
  export class DateRangePicker extends Component<{}, {}> { }
}

通过将其包装在模块语句中解决了此问题,如下所示:

import * as React from 'react';
declare class DateRangePicker extends React.Component<{}, {}> { }
{
  "compilerOptions": {
    "outDir": "./dist/",
    "sourceMap": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "module": "commonjs",
    "target": "es6",
    "jsx": "react",
    "typeRoots": [
      "./@types"
    ]
  },
  "include": [
    "./app/**/*",
    "./@types/**/*"
  ]
}
declare module 'react-dates' {
  import { Component } from 'react';
  export class DateRangePicker extends Component<{}, {}> { }
}
声明模块“反应日期”{
从“react”导入{Component};
导出类DateRangePicker扩展组件{}
}
请注意,导入语句必须位于模块块内,否则返回:

扩充中的模块名无效。模块'react dates'解析为'path/node_modules/react dates/index.js'处的非类型化模块,该模块无法扩充


你自己打字有进展吗?我只使用了图书馆的一小部分,但到目前为止我得到的是:你就是那个人!我已经寻找这个答案好几个小时了。