Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Need Help] 只要将useRequest结果导出就报ts(4023)错误 #217

Closed
XGAGX opened this issue Oct 7, 2023 · 1 comment
Closed

[Need Help] 只要将useRequest结果导出就报ts(4023)错误 #217

XGAGX opened this issue Oct 7, 2023 · 1 comment
Labels
2.x 2.x question Further information is requested ts typescript problem

Comments

@XGAGX
Copy link

XGAGX commented Oct 7, 2023

问题描述 Problem Description

想将service和useRequest二次封装方便使用,但发现只要将useRequest结果导出就报ts(4023)错误

其他信息 Other information

创建个新项目也是如此

可创建个新项目复现这个问题

import { useRequest } from 'vue-request'

export const newRequest = (service: () => Promise<any>) => useRequest(service)

错误信息:

导出的变量“newRequest”具有或正在使用外部模块“"xxxx/node_modules/vue-request/dist/types/index"”中的名称“QueryResult”,但不能为其命名。ts(4023)

环境:
vscode: 1.78.2
node: 16.17.1
typescript: 5.0.4

最小demo项目文件只要3个文件
如下

package.json

{
  "name": "demo",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "typescript": "^5.0.4",
    "vue-request": "^2.0.2"
  }
}

tsconfig.json

{
  "include": ["env.d.ts", "./**/*"],
  "compilerOptions": {
    "composite": true,
    "baseUrl": "."
  }
}

demo.ts

import { useRequest } from "vue-request";

export const newRequest = (service: () => Promise<any>) => useRequest(service);
@XGAGX XGAGX added the question Further information is requested label Oct 7, 2023
@XGAGX XGAGX changed the title 只要将useRequest结果导出就报ts(4023)错误 [Need Help] 只要将useRequest结果导出就报ts(4023)错误 Oct 7, 2023
@John60676 John60676 added ts typescript problem 2.x 2.x labels Oct 16, 2023
John60676 added a commit that referenced this issue Oct 16, 2023
@John60676
Copy link
Member

This has been fixed in 35b07a4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x 2.x question Further information is requested ts typescript problem
Projects
None yet
Development

No branches or pull requests

2 participants