Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
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 answers
Answer question

0

You could do

import { ReactElement } from "react";

and then

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

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 Report

0

you can add type to your helperTextt variable

let helperTextt: JSX.Element = null;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!