我有一个index.ts文件可以导出我所有的助手函数。为了以更方便的方式导入它们,我想使用export asTypeScript 3.8 的功能。所以这是我的代码:// index.tsexport * from './logging';export * as TypeHelper from './types';export * as ValidationHelper from './validation';这是我在运行时遇到的错误npm run serve:ERROR Failed to compile with 1 errors 13:44:55error in ./src/services/helpers/index.tsModule 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.jsYou 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.tsType checking in progress...No type errors foundVersion: typescript 3.9.7我怎样才能解决这个问题?
1 回答
牧羊人nacy
TA贡献1862条经验 获得超7个赞
根据 Mozilla 的说法,该语法不在当前规范中。那可能是 ES12
export * from …; // does not set the default export
export * as name1 from …; // Draft ECMAScript® 2O21
现在,您可以导入它们,然后再导出它们。
import * as TypeHelper from './types';
export TypeHelper;
添加回答
举报
0/150
提交
取消