reactjs - 用是的缺少属性反应正式打字稿
问题描述
我的问题是。我试图在 typescript 环境下使用 react-formal 和 yup。
我有这样非常简单的代码,这给了我错误:
import React from 'react';
import * as yup from 'yup';
import { ObjectSchema } from 'yup';
import Form from 'react-formal';
interface ITest {
name: string;
}
const FormalTest: React.FC = () => {
const schema: ObjectSchema<ITest> = yup.object<ITest>( {
name: yup.string().required().default( 'default' ),
} );
return (
<div>
<Form schema={ schema } defaultValue={ schema.default() }>
<Form.Field name="name" />
</Form>
</div>
);
};
VS Code 在线引发错误<Form schema={ schema } defaultValue={ schema.default() }>
Type 'ObjectSchema<ITest>' is missing the following properties from type 'ObjectSchema<object | undefined, object>': unknown, snakeCase, defined, optional, and 2 more. TS2740
我真的不知道问题是什么。
你有什么想法/建议吗?我不能从打字稿辞职。
我正在使用“react-formal”:“2.1.3”,“yup”:“0.28.3”,“react”:“16.12.0”,
解决方案
推荐阅读
- amazon-ec2 - 如果标签中存在冒号,ansible 无法模板化
- java - 如何使用 POI 更新特定单元格而不修改同一行的任何其他数据?
- python - 从 pyspark 中的 json 列表中提取值
- mysql - 我想链接phpmyadmin数据库中不同表中的两行
- apache-superset - 在哪里可以找到事件日志中事件的文档?
- visual-studio-code - vs-code:如何从命令行打开当前 WSL 文件夹 *as wsl*?
- junit - 我可以在我的测试类中覆盖 quarkus application.properties 值吗?
- python - 使用 Pandas 列中的起始值计算值(python)
- list - F# 创建从其他列表填充的新列表
- python - Tesseract OCR 未从图像中提取所有文本