Skip to content

Fix/ts type imports - #4081

Merged
song-xiao-lin merged 3 commits into
masterfrom
fix/ts-type-imports
Aug 10, 2026
Merged

Fix/ts type imports#4081
song-xiao-lin merged 3 commits into
masterfrom
fix/ts-type-imports

Conversation

@luoluoTH

@luoluoTH luoluoTH commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

概述

本 PR 基于 master 分支,修复了渲染端的 TypeScript 类型导入校验问题及相关 TS 报错,确保项目在 verbatimModuleSyntax: true 配置下通过 tsc 和 ESLint 检查。

改动内容

1. TS 类型导入修复 (import type)

  • 为主渲染端和 link 渲染端添加 ESLint 配置 (.eslintrc.cjs),启用 @typescript-eslint/consistent-type-imports 规则
  • 批量修复约 1000+ 个 TS1484 错误:将纯类型导入改为 import type { X } 或内联 import { type X }
  • 修复 global.d.ts 中的 import() type annotations(ESLint 禁止此语法),改为 import type * as Namespace + declare global

2. .d.ts 类型声明文件导入修复

  • .d.ts 文件的导入统一使用 import type { X }(整体),避免 Vite 在 verbatimModuleSyntax 下尝试解析声明文件路径导致 Failed to resolve import 错误
  • 修复多行 import { type X, type Y } from '...Type' 改为 import type { X, Y } from '...Type'

3. TS 类型错误修复

  • 修复 BufferUint8Array 类型不兼容:new Buffer(x)Buffer.from(x): Buffer 类型标注 → : Uint8Array
  • 优化 StringToUint8ArrayBuffer.from(str) as unknown as Uint8Array 零拷贝转型
  • 修复 YakitAutoComplete ref 类型不兼容(影响 10+ 文件)
  • 修复 MainOperatorContentYakitRoutestring 类型不兼容
  • 修复 YakitSelect options 可能为 undefined
  • 修复 import aliasverbatimModuleSyntax 下的 TS1288 错误

4. ESLint 规则修复

  • 修复 no-case-declarations:为 switch case 块中的 let/const 声明添加 {} 块级作用域(134 处)
  • 修复 prefer-const:将从未重新赋值的 let 改为 const(719 处)

5. CSS autoprefixer 警告修复

  • text-align: starttext-align: left
  • align-items: startalign-items: flex-start
  • justify-content: endjustify-content: flex-end
  • 同时修复 SCSS 文件和 TSX 内联样式

6. 其他

  • 修复 YakitSelectType.d.ts 中误加的 import { type } from 'os'
  • 修复 AuditCode.tsxsetQuery 不支持回调形式的问题
  • 修复 YakitAuditHoleTable.tsx 中 pagination 缺少 onChange 和属性重复指定

验证

  • npx tsc --noEmit:主渲染端和 link 渲染端均 0 错误
  • npx eslint src/ --ext .ts,.tsx:0 error
  • npx vite build(link 渲染端):构建成功
  • 新增依赖:eslint-plugin-react-hooks,关闭v7的验证,后续会启动

影响范围

  • 主渲染端 (app/renderer/src/main)
  • Link 渲染端 (app/renderer/engine-link-startup)
  • 不涉及业务逻辑改动,仅为类型导入和 ESLint 规则修复

第一种合并方式

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

PR CI 汇总

状态:全部通过

  • ✅ i18n(renderer src/main zh/zh-TW/en)
  • ✅ i18n(engine-link zh/zh-TW/en)
  • ✅ ESLint(renderer src/main)
  • ✅ TypeScript(renderer src/main)
  • ✅ ESLint(engine-link-startup)
  • ✅ TypeScript(engine-link-startup)
  • ✅ 图片/视频体积
  • ✅ Vitest(main / renderer / engine-link;test 同目录·别名·相对路径)
  • ✅ Prettier

由 pull_request test workflow 自动生成

@luoluoTH
luoluoTH force-pushed the fix/ts-type-imports branch 5 times, most recently from 7cb4fa2 to c9657ab Compare August 5, 2026 03:35
@luoluoTH
luoluoTH force-pushed the fix/ts-type-imports branch 5 times, most recently from 983c621 to ff6345e Compare August 5, 2026 06:14
luoluoTH and others added 2 commits August 7, 2026 17:51
feat:render和link渲染端增加ts导入校验
fix:修改或修复ts
perf:switch增加块级作用域
fix:修复Use 'const' instead
fix:Buffer和Uint8Array ts报错问题
fix:修复link渲染端得ts报错
fix:修复autoprefixer警告(end->flex-end)类似得警告
fix:关闭no-unused-vars
fix:修复ci检测后的报错
perf::引入依赖
fix:关闭v7中新增的规则
@luoluoTH
luoluoTH force-pushed the fix/ts-type-imports branch from 17e644a to 2aa5784 Compare August 7, 2026 09:52
@luoluoTH luoluoTH added ready Merge after publishing 发版后再合并 and removed need more test 需要更多的测试 labels Aug 7, 2026
@youngster-yj
youngster-yj requested a lite review from Copilot August 10, 2026 02:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@song-xiao-lin
song-xiao-lin merged commit 9f465c4 into master Aug 10, 2026
11 checks passed
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 this pull request may close these issues.

4 participants