Skip to content

refactor(types): enable noImplicitAny - #162

Merged
luojiyin1987 merged 1 commit into
masterfrom
refactor/enable-no-implicit-any
Aug 22, 2026
Merged

refactor(types): enable noImplicitAny#162
luojiyin1987 merged 1 commit into
masterfrom
refactor/enable-no-implicit-any

Conversation

@luojiyin1987

Copy link
Copy Markdown
Contributor

Closes #161

改动

  "package.json"
+    "@types/text-table": "^0.2.5"

  "tsconfig.json"
-    // TS 6 flips the effective noImplicitAny default to true. Pinned to keep
-    // the upgrade diff behavior-preserving; see format-lint-report.ts for the
-    // known implicit-any sites awaiting cleanup.
-    "noImplicitAny": false,

  "src/utils/format-lint-report.ts"
-        align: ["", "r", "l"],
+        // text-table treats undefined like "" (default alignment).
+        align: [undefined, "r", "l"],

根因说明

之前预估的 6 个隐式 any 是同一个根因:text-table 无类型声明 → table() 返回 any → 下游 .split()/.map()/.replace() 回调参数全部隐式 any。安装官方 @types/text-table 后,整条链获得上下文类型,只剩一个真实错误:

@types/text-tablealign 收紧为 "l" | "r" | "c" | "." | null | undefined,代码里的 "" 不在联合内。已核对 text-table 运行时源码(index.js 只比较 '.' / 'r' / 'c'):undefined"" 走同一条默认分支,替换可证等价、零行为变化。

callback 参数无需手写注解——类型全部来自 DT 声明的上下文推导。

验证

检查项 结果
npm run typecheck(noImplicitAny 开启) 通过
npm test -- --runInBand 25 suites / 205 tests 通过
npm run build + emit 检查 通过,仍为 CJS
npm run test:package 通过

@luojiyin1987
luojiyin1987 merged commit 4d664d3 into master Aug 22, 2026
7 checks passed
@luojiyin1987
luojiyin1987 deleted the refactor/enable-no-implicit-any branch August 22, 2026 06:06
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.

refactor(types): enable noImplicitAny

1 participant