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

128
Views
Cómo importar algunas funciones de un archivo pero no llenar el espacio de nombres del archivo con vars que tienen el mismo nombre pero también permiten la agitación del árbol

Estoy tratando de escribir mis importaciones de una manera que se pueda sacudir el árbol, pero tengo algunas funciones con el mismo nombre que en algunos otros archivos. ¿Hay alguna manera de importar todas estas funciones en el mismo archivo sin causar conflictos de nombres?

A continuación se muestra un ejemplo genérico:

 // Car.ts export function doSomething () { /* doSomething logic */ } export function doSomethingElse () { /* doSomethingElse logic */ } export function doA3rdThing () { /* doA3rdThing logic */ } // User.ts export function doSomething () { /* doSomething logic */ } export function doSomethingElse () { /* doSomethingElse logic */ } export function doA3rdThing () { /* doA3rdThing logic */ } // index.ts import { doSomething, doSomethingElse, doA3rdThing } from './Car' import { doSomething, doSomethingElse, doA3rdThing } from './User' // error: Duplicate identifier 'doSomething'. // error: Duplicate identifier 'doSomethingElse'. // error: Duplicate identifier 'doA3rdThing'.

Algo así sería genial:

 import { doSomething, doSomethingElse, doA3rdThing } as Car from './Car' import { doSomething, doSomethingElse, doA3rdThing } as User from './User' Car.doSomething() User.doSomething() // no longer duplicate identifiers and could be tree shakeable
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Prueba esto:

 import { doSomething as carDoSomething, doSomethingElse as carDoSomethingElse } from './Car' import { doSomething as userDoSomething, doSomethingElse as userDoSomethingElse } from './User'
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!