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

.ice 目录下的类型错误 #5939

Closed
ClarkXia opened this issue Feb 17, 2023 · 2 comments · Fixed by #5950
Closed

.ice 目录下的类型错误 #5939

ClarkXia opened this issue Feb 17, 2023 · 2 comments · Fixed by #5950
Assignees
Labels

Comments

@ClarkXia
Copy link
Collaborator

Summary | 概述

No response

Motivation | 背景

image

Usage example | 使用示例

No response

Detailed design | 方案设计

包下面增加 type.d.ts 文件以支持 exports 导入的类型提示

Additional context | 额外信息

No response

@ClarkXia ClarkXia added the rfc label Feb 17, 2023
@luhc228
Copy link
Collaborator

luhc228 commented Feb 17, 2023

方案

假设现在在 esm 目录有以下的 d.ts 产物:

esm
 ├── hooks.js
 ├── hooks.d.ts
 ├── request.js
 └──  request.d.ts

并且我们明确知道这两个文件是需要被导出的:

{
  "exports": {
    "./hooks": {
      "import": "./esm/hooks.js"
    },
   "./request": {
      "import": "./esm/request.js"
    }
  }
}

那么我们可以在根目录下新建两个 d.ts 文件:

├── hooks.d.ts
├── request.d.ts
└──  package.json
// hooks.d.ts
export * from './esm/hooks';

这样在 import hooks from 'your-package-name/hooks'; 的时候编辑器就不会报错了

@ClarkXia ClarkXia mentioned this issue Feb 21, 2023
12 tasks
@wssgcg1213
Copy link
Collaborator

@luhc228 所以这个本质原因是 exports 里面声明的导出也需要有同名的 .d.ts 文件吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants