转换React项目时Typescript调试失败

时间:2018-06-19 20:18:33

标签: reactjs typescript webpack

我正在尝试将现有的大量React项目转换为TypeScript。

我有webpack 2.7.0,ts-loader 3.5.0,typescript 2.9.2,source-map-loader 0.2.3和{{1 }}和react

这是我的react-dom

tsconfig.json

这是我的{ "compilerOptions": { "outDir": "./dist/", // path to output directory "sourceMap": true, // allow sourcemap support "strictNullChecks": true, // enable strict null checks as a best practice "module": "es6", // specify module code generation "jsx": "react", // use typescript to transpile jsx to js "target": "es5", // specify which target of JavaScript should be emitted from the given TypeScript "allowJs": true // allow a partial TypeScript and JavaScript codebase }, "include": [ "./src/" ] }

webpack.config.js

运行module: { rules: [ { test: /\.(t|j)sx?$/, exclude: /node_modules/, loader: 'ts-loader' }, { enforce: "pre", test: /\.js$/, loader: "source-map-loader" }, ...other stuff for css-loader and url-loader 时,我得到:

npm start

在开始我的TypeScript迁移之前,此版本有效,但现在不行。我还没有任何ERROR in ./src/app/index.js Module build failed: Error: Debug Failure. False expression. at getJSDocTags (C:\Path\to\nodemodules\typescript\lib\typescript.js:13197:22) at getFirstJSDocTag (C:\Path\to\nodemodules\typescript\lib\typescript.js:13205:24) at Object.getJSDocType (C:\Path\to\nodemodules\typescript\lib\typescript.js:13173:19) at getContextualSignature (C:\Path\to\nodemodules\typescript\lib\typescript.js:41002:32) at checkFunctionExpressionOrObjectLiteralMethod (C:\Path\to\nodemodules\typescript\lib\typescript.js:44621:43) at checkExpressionWorker (C:\Path\to\nodemodules\typescript\lib\typescript.js:45681:28) at checkExpression (C:\Path\to\nodemodules\typescript\lib\typescript.js:45609:42) at checkExpressionCached (C:\Path\to\nodemodules\typescript\lib\typescript.js:45457:38) at getWidenedTypeFromJSSpecialPropertyDeclarations (C:\Path\to\nodemodules\typescript\lib\typescript.js:30757:46) at getTypeOfVariableOrParameterOrProperty (C:\Path\to\nodemodules\typescript\lib\typescript.js:31032:28) at getTypeOfSymbol (C:\Path\to\nodemodules\typescript\lib\typescript.js:31242:24) at checkPropertyAccessExpressionOrQualifiedName (C:\Path\to\nodemodules\typescript\lib\typescript.js:42338:53) at checkPropertyAccessExpression (C:\Path\to\nodemodules\typescript\lib\typescript.js:42293:20) at checkExpressionWorker (C:\Path\to\nodemodules\typescript\lib\typescript.js:45663:28) at checkExpression (C:\Path\to\nodemodules\typescript\lib\typescript.js:45609:42) at checkBinaryLikeExpression (C:\Path\to\nodemodules\typescript\lib\typescript.js:45155:29) @ multi (webpack)-dev-server/client?http://0.0.0.0:8080 webpack/hot/dev-server ./src/app/index.js ts文件。一切都只是tsx / js

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

我刚才遇到了完全相同的问题,找不到任何文档可以帮助我。看起来像2.9中的Typescript错误。

尝试升级typescript @ next(今天是3.0.0-dev.20180703)。那使我无法接受!