node.js - 如何设置节点模块导出类型信息
问题描述
我正在编写一个节点模块,它是我的反应和反应本机应用程序的 api 层。我已经达到了打字稿导出除type
对象之外的所有内容的地步。据我了解,我可以为我的项目创建自定义类型,但这似乎没有必要。这是我编译的index.d.ts
文件的样子
import InventoryService from "./src/services/InventoryService";
import PlentiItemService from "./src/services/PlentiItemService";
...
declare type PlentiType = "Fruit" | "Decorative" | "Herb" | "Poultry" | "Vegetable" | "Unknown";
declare type QuantityName = "None" | "A Little" | "Some" | "A Lot" | "Many";
export { AccountLoginForm, AccountSignupForm, AccountUpdateForm, ..., PlentiType, QuantityName}
请注意,这些类型已导出,但在安装应用程序中似乎不可用。这是为什么?
解决方案
请注意,类型已导出,但在安装应用程序中似乎不可用。这是为什么
假设你"main" : "lib"
的 package.json 中有(js 文件的路径),你的 package.json 中也需要有 `"types": "lib" (.d.ts 文件的路径)。
如果您没有.d.ts
编译出文件,请确保您tsconfig.json
有declaration: true
更多的
推荐阅读
- go - jQuery 的第 n 个子方法等价于什么?
- kubernetes - Kubernetes 仪表板不接受通过 HTTP 的服务帐户令牌:身份验证失败。请再试一次
- c# - Microsoft 认知语音服务 - 语音转文本批量转录权限错误
- amazon-web-services - 表自动删除,无需采取任何措施导致此问题
- c# - 如何在 Asp.net MVC C# 中使用 Linq 从多个表中选择具有最大计数值的记录
- c++ - av_buffersink_get_frame() 返回错误 AVERROR(EAGAIN) -11
- excel - 如果它有 <30 行,则要删除整个列
- c# - 错误:NullReferenceException:对象引用未设置为对象的实例
- c# - 为什么删除命令没有从 C# 执行?
- cassandra - nodetool 命令在 cassandra 2.2.3 版中不起作用?