[RFC] tsconfig 是否应该开启 strict 或 strictNullChecks
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- typescript
- 领域
- build-system
调研方向
首先检查仓库的 tsconfig 和 useMergedState.ts 示例,尤其是第 19 行附近的泛型声明,以及大约从第 60 行开始的 effect。结合链接的 pro-components issue 了解上下文,然后确定启用 strict 或 strictNullChecks 是否合适,并定义由此产生的类型安全验收标准。
由索引模型根据 Issue 内容生成。
描述
WHY:不开启strictNullChecks的话会忽略所有的 null 和 undefined
举个例子:
useMergedState 中接受了泛型T作为内部的 innerValue 类型,但根据 L60 开始的代码
// Sync value back to `undefined` when it from control to un-control
useLayoutUpdateEffect(() => {
if (!hasValue(value)) {
setInnerValue(value);
}
}, [value]);
实际上 innerValue 的类型是T | undefined,因为没有开启 strictNullChecks 导致没有警告
该函数使用中,需要显性去指定泛型为 T | undefined 才能获取到实际正确的类型,如:
const [v] = useMergedState<string[]>(...) => const [v] = useMergedState<string[] | undefined>(...)
前者的写法,v的类型会忽略 undefined类型,导致后续编码产生错误
以上为我在debug该issue时发现: https://github.com/ant-design/pro-components/issues/6652
个人见解,欢迎讨论😁
- 主要语言
- TypeScript
- 星标
- 670
- 派生
- 206
- 平均合并
- 18 小时 59 分钟
- 30 天内合并 PR
- 1
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
react-component/util 的其他 Issue
-
isEqual: false 'circular references' warning for a reference repeated across sibling keys可能已有人在做 @savkaoleg 于 19 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
react-component/util#816 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
react-component/util#671 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
react-component/util#738 · 1 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 25/100
react-component/util#710 ·
-
难度 3/5 1-2 天 新手友好度 25/100
react-component/util#647 · 5 条评论 ·
查看 react-component/util 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
AOSSIE-Org/DebateAI#611 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
openzim/mwoffliner#2933 ·
维护者通常 1 天内回复
-
Use the README category name for website links and submissions可能已有人在做 @dajiaohuang 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
birobirobiro/awesome-shadcn-ui#647 ·
维护者通常 2 天内回复
-
Twake Drive picker: closePicker() never destroys the intent (stop() is on the promise returned by start(), not by create())可能已有人在做 @chibenwa 今天认领。 未关闭claude
难度 2/5 1-3 小时 新手友好度 84/100
linagora/twake-calendar-frontend#1498 · 1 条评论 ·
维护者通常 1 天内回复
-
check:passed streams:add
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复