typescript – 使用wallaby测试时出现意外的保留字错误

前端之家收集整理的这篇文章主要介绍了typescript – 使用wallaby测试时出现意外的保留字错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在我编写测试用例的测试文件中,我导入了一个打字稿文件,如下所示: @H_403_2@import {rootReducer} from "../src/reducers/rootReducer";

在rootReducer.ts中,我导入了另一个打字稿文件,如下所示:

@H_403_2@import taskReducer from "./taskReducer.ts";

然后它显示错误

@H_403_2@SyntaxError: Unexpected reserved word at src/reducers/rootReducer.ts:7

rootReducer.ts和taskReducer.ts都位于文件夹/ src / reducers下

如果从import语句中删除“.ts”,但在浏览器中抛出错误,则没有失败的测试.该应用程序将无法运行

小袋鼠配置如下:

@H_403_2@module.exports = function (wallaby) { return { files: [ 'src/*.ts','src/**/*.ts' ],tests: [ 'test/*Test.ts' ],testFramework: "mocha",env: { type: 'node' },compilers: { '**/*.ts': wallaby.compilers.typeScript({ /* 1 for CommonJs*/ module: 1 }) } } };

解决方法

你的陈述: @H_403_2@import taskReducer from "./taskReducer.ts";

应该是:

@H_403_2@// Import just taskReducer from this module import {taskReducer} from "./taskReducer";

要么:

@H_403_2@// Import the whole module and call it taskReducer import * as taskReducer from "./taskReducer";

猜你在找的JavaScript相关文章