Typescript 在package.json中指定多个类型定义文件

Typescript 在package.json中指定多个类型定义文件,typescript,typescript-typings,typescript2.0,Typescript,Typescript Typings,Typescript2.0,我正在为节点库[1]创建类型定义,但在组织文件时遇到了问题 我在package.json中添加了typings字段,效果很好,但问题是我想指定多个类型定义文件,因为库本身分为两个入口点: 样式化组件 样式化组件/本机 因此,我已经为这两个入口点创建了类型定义,但我不确定如何正确使用typings字段。这是我的结构(我只包括相关内容): 在styled components.d.ts中,我有一些主要的定义,应该从“styled components”导入样式。 在styled componen

我正在为节点库[1]创建类型定义,但在组织文件时遇到了问题

我在package.json中添加了
typings
字段,效果很好,但问题是我想指定多个类型定义文件,因为库本身分为两个入口点:

  • 样式化组件
  • 样式化组件/本机
因此,我已经为这两个入口点创建了类型定义,但我不确定如何正确使用
typings
字段。这是我的结构(我只包括相关内容):

styled components.d.ts
中,我有一些主要的定义,应该从“styled components”导入
样式。
在
styled components native.d.ts
中,我有本机入口点的定义,应该从“styled components/native”导入{x}

package.json中的
typings
字段指向
typings/styled components.d.ts
,但这并不能使
styled components native.d.ts
定义可用

我还尝试使用
index.d.ts
并引用(使用三重斜杠表示法)其他两个文件,但都不起作用

那么有没有办法做到这一点呢

[1] 这是我的公关

试试看:

├── index.js
├── index.d.ts
├── native.js
├── native.d.ts
应该能正常工作,因为这就是像
@angular/material
这样的包为此类导入绑定其类型的方式

基本上,typescript编译器将查找与javascript文件同名的
.d.ts
文件

(编辑:抱歉,我没意识到这个问题太老了……无论如何,我会把答案留在这里,以防对某人有所帮助)

├── index.js
├── index.d.ts
├── native.js
├── native.d.ts