Javascript Vue:使用“时模块解析失败”;出口*为“出口”;打字
我有一个Javascript Vue:使用“时模块解析失败”;出口*为“出口”;打字,javascript,node.js,typescript,vue.js,vuejs2,Javascript,Node.js,Typescript,Vue.js,Vuejs2,我有一个index.ts文件来导出我的所有助手函数。为了更方便地导入它们,我想使用TypeScript 3.8的导出为功能 这是我的代码: //index.ts 从“./logging”导出*; 从“./types”导出*作为TypeHelper; 从“/validation”导出*作为ValidationHelper; 这是我在运行npm run service时遇到的错误: ERROR Failed to compile with 1 errors
index.ts
文件来导出我的所有助手函数。为了更方便地导入它们,我想使用TypeScript 3.8的导出为功能
这是我的代码:
//index.ts
从“./logging”导出*;
从“./types”导出*作为TypeHelper;
从“/validation”导出*作为ValidationHelper;
这是我在运行npm run service
时遇到的错误:
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
如何修复此问题?根据Mozilla的说法,该语法不在当前规范中。可能是ES12
export*from…;//不设置默认导出
从…;//导出*作为名称1ECMAScript®2O21草案
现在,您可以导入它们,然后重新导出它们
import*作为“./types”中的TypeHelper;
导出TypeHelper;