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

190
Vistas
Type 'Element' is not assignable to type 'string'.ts(2322)

I'm new react typescript developer, here i have a code which works in 'js' 'but when changed to 'tsx' getting error: Type 'Element' is not assignable to type 'string'.ts(2322) it is pointing to 'helperTextt' error (did not find answer else where) should i do : let helperTextt:any = ""; ?

any suggestions ?

let helperTextt = "";

if (event.target.id === "hostname") {
  if (!HOSTNAME_REGEX.test(event.target.value)) {
    helperTextt = (
      <Trans i18nKey="form.formData.hostNameError">
        Invalid Host name
      </Trans>
    );
    errorr = true;
  }
}

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You could do

import { ReactElement } from "react";

and then

let helperTextt: ReactElement | null = null;
about 4 years ago · Juan Pablo Isaza Denunciar

0

Typescript is automatically inferring helperTexttto be a string, if you are certain of its values you can get around this (although it is not preferred to declare type any) by declaring it as type any:

 let helperTextt:any;
about 4 years ago · Juan Pablo Isaza Denunciar

0

you can add type to your helperTextt variable

let helperTextt: JSX.Element = null;
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