重新删除从台词中的嵌套模块导入的

发布于 2025-02-11 05:46:04 字数 612 浏览 1 评论 0原文

我有一个带有嵌套模块myRequest的打字稿模块myapi,该模块,它允许我基于Myapi的构建目标(即浏览器或节点)为我的API请求使用不同的功能。

我的请求功能的返回类型是在myrequest中定义的。不幸的是,当我从myapi导入功能时,它不会跟踪返回类型,而只是将其投入到任何类型中。

如果我查看导出的TypeScript D.TS文件,我会发现在文件的顶部,Bundler(Parcel)会生成语句,

import {returnType} from "./myRequest"

但是当我尝试遵循这些类型时,我的IDE告诉我,MyRequest找不到定义。

我希望在Typescript中有一个选项可以重新出口导入的类型,以便它们以类型的完整类型定义出现。D.TS,而不是作为导入语句。

我尝试将的导出 *从“ MyRequest”添加到Myapi的index.ts.ts,但这并没有改变。

我还尝试在我的tsconfig.json文件中设置“ alimatedModules”:true没有结果。

如何让打字稿跟踪嵌套模块中的类型?

I have a typescript module myApi with a nested module myRequest which allows me to use different functions for my API requests based on the build target of myApi (i.e. browser or node).

the return types of my request functions are defined in myRequest. Unfortunately, when I import a function from myApi, it will not keep track of the return types and just cast them to any.

if I look at the exported typescript d.ts file I see that at the top of the file the bundler (parcel) generates a statement

import {returnType} from "./myRequest"

but when I try to follow these types my IDE tells me that no definition has been found for myRequest.

I would expect an option in typescript to re-export imported types such that they appear with their full type definition in types.d.ts rather than just as an import statement.

I tried to add an export * from "myRequest" to the index.ts of myApi but that did not make a difference.

I also tried to set "isolatedModules":true in my tsconfig.json file without results.

How can I have typescript keep track of the types in my nested module?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文