x-render icon indicating copy to clipboard operation
x-render copied to clipboard

schema里的format使用字符串类型会报ts类型错误

Open waleiwalei opened this issue 3 years ago • 2 comments

1.依赖仓库的版本(Dependencies versions)

  • react:18.1.0
  • form-render:1.10.1
  • table-render:
  • antd:

2.问题描述(Bug description): 使用ts类型检查时,schema内传入format参数会提示类型错误:string与联合类型不兼容,看了下type参数也是直接传的字符串到联合类型参数里,但是type加了一个(string & {})导致任意字符串都可以传进去,但是format没有写这个,导致类型报错,给format加上as const才能匹配

3.最小复现 demo(Reproduction demo)

const form = useForm()
const schema={type: 'object', properties: {"uploader": {
          "title": "上传文件",
          "type": "string",
          "format": "upload",
          "props": {
            "action": "https://www.mocky.io/v2/5cc8019d300000980a055e76"
          }
        }}}

  <FormRender schema={schema} form={form} />

form-render demo https://codesandbox.io/s/unruffled-flower-jl78h table-render demo https://codesandbox.io/s/sweet-euler-bdoty fr-generator demo https://codesandbox.io/s/s13sh

waleiwalei avatar Jun 20 '22 08:06 waleiwalei

displayType: 'row' as const 也有这个问题

waleiwalei avatar Jun 20 '22 09:06 waleiwalei

有人看下这个问题吗,遇到一样的情况

lintingjie avatar Jun 28 '22 01:06 lintingjie

import FR, { Schema } from 'form-render'

const schema: Schema = {...}
<FR schema={schema} />

安装 [email protected] ,本周四发正式版。

siyi98 avatar Sep 21 '22 13:09 siyi98