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

248
Vistas
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
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