alovajs / alova

Workflow-Streamlined next-generation request tools. Extremely streamline API integration workflow, just one step
https://alova.js.org
MIT License
2.97k stars 109 forks source link

修复 `export = xxx` 的写法在 typescript 5.6.x 下报错的问题 #545

Closed mamboer closed 1 month ago

mamboer commented 2 months ago

相关 Issue / Related Issue

539

这个 PR 是什么类型?/ What type of PR is this?

这个 PR 做了什么?/ What does this PR do?

修复 export = xxx 的写法在 typescript 5.6.x 下报错:

alova/typings/fetch"' has no default export

文档 / Docs

无文档

测试 / Testing

changeset-bot[bot] commented 2 months ago

⚠️ No Changeset found

Latest commit: b54dc26f1cfe32a94b7736b25dedd7e3d897d87d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

JOU-amjs commented 2 months ago

export = xxx是为了兼容esModule和commonjs的写法,typescript也给出了esModuleInterop的配置项处理这种情况,经验证你的写法在commonjs中是无效的

mamboer commented 1 month ago

没有考虑到 commonjs 的情况哈, 不过奇怪的是 tsconfig.json 里面设置了 esModuleInteropallowSyntheticDefaultImports 均为 true,还是会报这个错误。

JOU-amjs commented 1 month ago
  1. 从node_modules检查ts版本 5.5,5.6貌似有bug
  2. 检查是否用了编辑器的ts版本