Reputation: 14777
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?
Upvotes: 0
Views: 627
Reputation: 29109
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;
Upvotes: 2