We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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>(...)
const [v] = useMergedState<string[]>(...)
const [v] = useMergedState<string[] | undefined>(...)
前者的写法,v的类型会忽略 undefined类型,导致后续编码产生错误
以上为我在debug该issue时发现: ant-design/pro-components#6652
个人见解,欢迎讨论😁
The text was updated successfully, but these errors were encountered:
@MadCcc @zombieJ
大佬们cc
Sorry, something went wrong.
No branches or pull requests
WHY:不开启strictNullChecks的话会忽略所有的 null 和 undefined
举个例子:
useMergedState 中接受了泛型T作为内部的 innerValue 类型,但根据 L60 开始的代码
实际上 innerValue 的类型是T | undefined,因为没有开启 strictNullChecks 导致没有警告
该函数使用中,需要显性去指定泛型为 T | undefined 才能获取到实际正确的类型,如:
const [v] = useMergedState<string[]>(...)
=>const [v] = useMergedState<string[] | undefined>(...)
前者的写法,v的类型会忽略 undefined类型,导致后续编码产生错误
以上为我在debug该issue时发现: ant-design/pro-components#6652
个人见解,欢迎讨论😁
The text was updated successfully, but these errors were encountered: