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

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 1:[1]

I ended up using two-liners, such as:

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

Solution 2:[2]

You can either export all the elements from a module like below (no renaming allowed):

export * from '../file.ts';

Or you can export specific elements and rename them as you see fit:

export {Class1, Class2 as Class3} from '../file.ts';

Documentation for re-exports: https://www.typescriptlang.org/docs/handbook/modules.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MojioMS
Solution 2 Behrooz