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

180
Views
Agregue una nueva propiedad de símbolo conocida como Symbol.myProperty en TypeScript

En JavaScript tenemos un símbolo global en el objeto Symbol , como Symbol.iterator y Symbol.match .

Puedo asignar la propiedad borrando el tipo a any , sin embargo, TypeScript no lo reconoce.

 // Define Symbol.hello (Symbol as any).hello = Symbol("hello"); // Try using it later: Symbol.hello; // TypeScript error: Property 'hello' does not exist on type 'SymbolConstructor'.ts(2339)

¿Cómo agrego mi propiedad a Symbol de una manera que haga feliz a TypeScript?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede declarar su propiedad en la interfaz de SymbolConstructor :

 declare global { interface SymbolConstructor { readonly hello: symbol; } }

Ahora puede definir su propiedad:

 // Define Symbol.hello (Symbol as { hello: symbol }).hello = Symbol("hello"); // TypeScript is now happy: Symbol.hello;
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!