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

240
Views
obteniendo un error en TypeScript: el tipo 'cadena []' no se puede asignar al tipo 'cadena'.ts (2345)

Intentando agregar un elemento de intervalo a una cadena reemplazando las comas. Pero obtener el código de error anterior en mi código jquery.

por ejemplo, lo que estoy tratando de lograr:

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

entonces esa cadena se convierte en:

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

Esta es mi sección de código, está basada en stencil.js

La línea que causa el error es

 $('.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> } }

El error completo es el siguiente:

 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!