0

I have an index.ts file to export all of my helpers functions. To import them in a more convenient way I want to use the export as functionality of TypeScript 3.8.

So this is my code:

// index.ts
export * from './logging';
export * as TypeHelper from './types';
export * as ValidationHelper from './validation';

This is the error I get when running npm run serve:

ERROR  Failed to compile with 1 errors                                                                                                                                               13:44:55

error  in ./src/services/helpers/index.ts

Module parse failed: Unexpected token (2:9)
File was processed with these loaders:
 * ./node_modules/cache-loader/dist/cjs.js
 * ./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader/index.js
 * ./node_modules/eslint-loader/index.js
You may need an additional loader to handle the result of these loaders.
| export * from './logging';
> export * as TypeHelper from './types';
| export * as ValidationHelper from './validation';
| 

 @ ./src/plugins/router/index.ts 3:0-41 92:8-11 98:8-11
 @ ./src/main.ts
 @ multi (webpack)-dev-server/client?http://192.168.179.4:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts

Type checking in progress...
No type errors found
Version: typescript 3.9.7

How can I fix this?

1 Answer 1

2

According to Mozilla, that syntax is not in the current spec. That would be possibly ES12

export * from …; // does not set the default export
export * as name1 from …; // Draft ECMAScript® 2O21

For now, you can import them, and then reexport them.

import * as TypeHelper from './types';
export TypeHelper;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.