Home > Net >  Is there some way to "spread" object properties to parameters of a function definition?
Is there some way to "spread" object properties to parameters of a function definition?

Time:04-28

Best explained in code:

const ROUTE_PARAMS = {
  userId: 'userId',
  companyId: 'companyId',
};

// Is this somehow possible?
// `typeof` is obviously not the right tool here, just used as an example.
function buildRoute(typeof ROUTE_PARAMS): string;

// Result should be similar to:
function buildRoute2(userId: string, companyId: string): string;

//            
  • Related