在另一个 Typescript 库中包含 Typescript 库
Include Typescript library in another Typescript library
我有一个 github 打字稿库,我想使用
安装它
npm install --save git+ssh://git@github.com:User/mylib.git
在我的目标节点服务中,它也在 Typescript 中。
如何在类型安全的情况下完成这项工作?我想知道在编译我的服务时是否有任何类型不匹配。
I'd like to know if there are any type mismatches when I compile my service.
确保您的图书馆有:
tsconfig.json
: outDir
和 declaration:true
typings
指向 outDir
例子
TypeStyle 附带 TypeScript 定义:https://github.com/typestyle/typestyle
这是我们最终使用的:
在正在导出的打字稿库(@myuser/lib1)中,我们在package.json
中添加了以下行
"types":“./src/index.ts”或“./src/index.d.ts”
在使用上述库的typescript服务中,我们将其导入为:
npm install --save @myuser/lib1
这安装了带有类型的库并通过类型安全检查编译您的服务。
我有一个 github 打字稿库,我想使用
安装它npm install --save git+ssh://git@github.com:User/mylib.git
在我的目标节点服务中,它也在 Typescript 中。
如何在类型安全的情况下完成这项工作?我想知道在编译我的服务时是否有任何类型不匹配。
I'd like to know if there are any type mismatches when I compile my service.
确保您的图书馆有:
tsconfig.json
:outDir
和declaration:true
typings
指向 outDir
例子
TypeStyle 附带 TypeScript 定义:https://github.com/typestyle/typestyle
这是我们最终使用的:
在正在导出的打字稿库(@myuser/lib1)中,我们在package.json
"types":“./src/index.ts”或“./src/index.d.ts”
在使用上述库的typescript服务中,我们将其导入为:
npm install --save @myuser/lib1
这安装了带有类型的库并通过类型安全检查编译您的服务。