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

242
Views
getting error in TypeScript : Type 'string[]' is not assignable to type 'string'.ts(2345)

Trying to add span element to a string by replacing the commas. But getting above error code in my jquery code.

for example What I am trying to accomplish:

this.prop.city == "los angeles, new york, boston"

then that string turns into:

<span>los angeles</span> <span>new york</span> <span>boston</span>

This is my code section it is based on stencil.js

The line causing the error is

        $('.tag').html($('.tag').html().split(', ').map(function(el) {return '<span>' + el + '</span>'}));
  @Component({
    tag: 'stencil-component-text',
})
export class stencilComponentText {
    @Prop() prop: any;

      componentDidLoad() {

        $('.tag').html($('.tag').html().split(', ').map(function(el) {return '<span>' + el + '</span>'}));
    }

       render() {
        if (this.prop.countryCode && this.prop.city) {
            if(this.prop.city.includes(',')){

                return  <span class="testing">{this.prop.countryCode} - <span class="tag">{this.prop.city}</span>, {this.prop.state}</span>
            } 
     }

Full error is as follows:

Argument of type 'string[]' is not assignable to parameter of type
          'string | Element | Text | Comment | DocumentFragment | ((this:
          HTMLElement, index: number, oldhtml: string) => string | Element |
          Text | Comment | DocumentFragment)'. Type 'string[]' is not
          assignable to type 'string'.
about 4 years ago · Juan Pablo Isaza
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!