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

启用 ts config:importsNotUsedAsValues #3952

Open
wants to merge 3 commits into
base: preview-features
Choose a base branch
from

Conversation

timongh
Copy link
Contributor

@timongh timongh commented Jan 28, 2023

同时开启相应的 eslint 规则:@typescript-eslint/consistent-type-imports

启用该规则后,代码中所有仅作为类型使用的导入,都必须使用 import type

这个 PR 里用 eslint --fix 批量修改了代码中的导入(顺便给导入排了序)

Vue3 的 <script setup> 需要启用该规则,见:https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#preserve-value-imports

@timongh
Copy link
Contributor Author

timongh commented Jan 28, 2023

有类型错误,我知道的有两个解决方法:

  1. 将 Options 从 interface 改为类型别名
  2. 在 Options 的定义里添加 [K:string]: unknown

虽然我不知道为什么……

@the1812
Copy link
Owner

the1812 commented Jan 29, 2023

Vue3 的 <script setup> 需要启用该规则,见:https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#preserve-value-imports

看了下 TS 也该升级了, 我这太老了, 升级后才可以用新的 type import 语法
image

@timongh
Copy link
Contributor Author

timongh commented Jan 29, 2023

所以要我在 PR 里直接更新了吗?

@the1812
Copy link
Owner

the1812 commented Jan 29, 2023

我来吧

@the1812
Copy link
Owner

the1812 commented Feb 5, 2023

已升级 TS 4.9 (abbc4eb)

@timongh
Copy link
Contributor Author

timongh commented Feb 19, 2023

有类型错误,我知道的有两个解决方法:

  1. 将 Options 从 interface 改为类型别名
  2. 在 Options 的定义里添加 [K:string]: unknown

我指的是 src/components/i18n/types.ts 里的类型定义 Options。合并的时候把这里改一下就没有类型错误了。

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

Successfully merging this pull request may close these issues.

None yet

2 participants