Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

341
Vistas
Type 'string' cannot be assigned to type 'UploadFileStatus | undefined'
    import React, { useState } from 'react';
    import { Upload } from 'antd';
    import ImgCrop from 'antd-img-crop';

    interface uploadProps{
      fileList:string;

    }
    const UploadD:React.FC <uploadProps> = () => {
      const [fileList, setFileList] = useState([
        {
          uid: '-1',
          name: 'image.png',
          status: 'done',
          url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
        },
      ]);

      const onChange = ({ fileList: newFileList }) => {
        setFileList(newFileList);
      };

      const onPreview = async file => {
        let src = file.url;
        if (!src) {
          src = await new Promise(resolve => {
            const reader = new FileReader();
            reader.readAsDataURL(file.originFileObj);
            reader.onload = () => resolve(reader.result);
          });
        }
        const image = new Image();
        image.src = src;
        const imgWindow = window.open(src);
        imgWindow!.document.write(image.outerHTML);
      };

      return (
        <ImgCrop rotate>
          <Upload
            action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
            listType="picture-card"
            fileList={fileList}//this error:Type 'string' cannot be assigned to type 'UploadFileStatus | undefined'.
            onChange={onChange}
            onPreview={onPreview}
          >
            {fileList.length < 5 && '+ Upload'}
          </Upload>
        </ImgCrop>
      );
    };

    export default UploadD

ERROR

Type '{ uid: string; name: string; status: string; url: string; }[]' cannot be assigned to type 'UploadFile<any>[]'.
   Type '{ uid: string; name: string; status: string; url: string; }' cannot be assigned to type 'UploadFile<any>'.
     The types of property 'status' are incompatible.
       Type 'string' cannot be assigned to type 'UploadFileStatus | undefined'. ts(2322)
interface.d.ts(70, 5): Required type from property "fileList", on type "IntrinsicAttributes & UploadProps<any> & { children?: ReactNode; } & RefAttributes<any>" here
      
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think because you are assigning string to UploadFileStatus | undefined. UploadFileStatus can be one of error | success | done | uploading | removed.

Try to use the type assertion :

const [fileList, setFileList] = useState([
        {
          uid: '-1',
          name: 'image.png',
          status: 'done' as UploadFileStatus,
          url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
        },
      ]);


about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda