我发现有很多关于 stackover flow 的类似讨论,但我认为这与 Typescript 版本有关,因为我的代码在使用 typescript 4.2.4 时没有问题。
我的代码如下。
...
const formik = useFormik({
initialValues: {
title: "",
link: "",
content: "",
post_type: "",
},
...
});
<TextField
{...params}
label="Post Type"
variant="outlined"
margin="normal"
error={formik.touched.post_type && Boolean(formik.errors.post_type)} //on "error"props, I am having error notification on vscode
helperText={formik.errors.post_type}
inputProps={{
...params.inputProps,
}}
/>
即使它有错误通知,但代码有效。版本 4.2.4 的 Typescript 没有错误通知,但我在 4.4.0-dev 上收到此错误通知
我很想知道为什么我会遇到错误以及如何解决。
提前致谢。