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

216
Views
is it bad a practice to export object with functions as properties from Typescript module?

I have a typescript module with some functions that i want to export. Lets call that module - service.ts

//service.ts

export const firstFunction = () => {}
export const secondFunction = () => {}

Now i can use those functions in some other file, lets call it consumer.ts

//consumer.ts 
import {firstFunction, secondFunction} from 'service.ts'

firstFunction()
secondFunction()

MY WISH to access those functions through an object like this

//consumer.ts 
import ??? from 'service.ts'

service.firstFunction()
service.secondFunction()

SOLUTION 1 - asterisk import - i don't want this solution

PROBLEM 1 - visual studio code can't autoimport service when i want to use it

//consumer.ts 
import * as service from 'service.ts'

service.firstFunction()
service.secondFunction()

SOLUTION 2 - export object - I like this solution

PROBLEM 2 - i don't know if this is a bad practice

//service.ts
const firstFunction = () => {}
const secondFunction = () => {}

export const service = { firstFunction, secondFunction }
//consumer.ts 
import {service} from 'service.ts'

service.firstFunction()
service.secondFunction()
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!