Create container module – export * as x from 'y'

Issue

I have this in a module:

export const Category = require('./category');
export const Roles = require('./roles');
export const FunctionalTeams = require('./functional-team');
export const WorkSteams = require('./workstream');

I tried changing it to TS imports:

export * as Category from './category';
export * as Roles from './roles';
export * as FunctionalTeams from './functional-team';
export * as WorkSteams from'./workstream';

but that doesn’t work, tsc doesn’t even recognize that syntax, I see these errors:

models/enums/index.ts(17,22): error TS1005: ';' expected.
models/enums/index.ts(17,27): error TS1005: ';' expected.
models/enums/index.ts(18,10): error TS1005: 'from' expected.
models/enums/index.ts(18,13): error TS1005: ';' expected.
models/enums/index.ts(18,19): error TS1005: ';' expected.

Solution

I ended up using two-liners, such as:

import * as Category from './category';
export Category;

Answered By – MojioMS

Answer Checked By – Pedro (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.