TypeScript: Typescript 2.1.4 + webpack + ts-loader: Unhandled rejection TypeError: Cannot read property 'getOptionsDiagnostics' of undefined

TypeScript Version: 2.1.4

Expected behavior: Webpack compiles my project (it compiles fine when using Typescript 2.1.1 or 2.0.10) There has also been a separate bug filed at ts-loader here. If you follow that thread to the end, you will see that various versions of ts-loader have been tested against Typescript and it seems to point to an issue with version 2.1.4.

Actual behavior: Webpack throws the following error:

Unhandled rejection TypeError: Cannot read property 'getOptionsDiagnostics' of undefined at Object.getCompilerOptionsDiagnostics (/Users/romiem/my-project/node_modules/typescript/lib/typescript.js:79004:27) at provideCompilerOptionDiagnosticErrorsToWebpack (/Users/romiem/my-project/node_modules/ts-loader/dist/after-compile.js:33:92) at Compiler.<anonymous> (/Users/romiem/my-project/node_modules/ts-loader/dist/after-compile.js:14:9) at Compiler.next (/Users/romiem/my-project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:69:14) at Compiler.<anonymous> (/Users/romiem/my-project/node_modules/webpack/lib/CachePlugin.js:40:4) at Compiler.applyPluginsAsync (/Users/romiem/my-project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:71:13) at Compiler.<anonymous> (/Users/romiem/my-project/node_modules/webpack/lib/Compiler.js:400:9) at Compilation.<anonymous> (/Users/romiem/my-project/node_modules/webpack/lib/Compilation.js:577:13) at Compilation.applyPluginsAsync (/Users/romiem/my-project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:60:69) at Compilation.<anonymous> (/Users/romiem/my-project/node_modules/webpack/lib/Compilation.js:572:10) at Compilation.applyPluginsAsync (/Users/romiem/my-project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:60:69) at Compilation.<anonymous> (/Users/romiem/my-project/node_modules/webpack/lib/Compilation.js:567:9) at Compilation.next (/Users/romiem/my-project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:67:11) at ExtractTextPlugin.<anonymous> (/Users/romiem/my-project/node_modules/extract-text-webpack-plugin/index.js:309:4) at Compilation.applyPluginsAsync (/Users/romiem/my-project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:71:13) at Compilation.<anonymous> (/Users/romiem/my-project/node_modules/webpack/lib/Compilation.js:563:8) at Compilation.next (/Users/romiem/my-project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:67:11) at ExtractTextPlugin.<anonymous> (/Users/romiem/my-project/node_modules/extract-text-webpack-plugin/index.js:285:5) at /Users/romiem/my-project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:52:16 at Object.async.forEachOf.async.eachOf (/Users/romiem/my-project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:236:30) at Object.async.forEach.async.each (/Users/romiem/my-project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:209:22) at ExtractTextPlugin.<anonymous> (/Users/romiem/my-project/node_modules/extract-text-webpack-plugin/index.js:237:10) at Compilation.applyPluginsAsync (/Users/romiem/my-project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:71:13) at Compilation.seal (/Users/romiem/my-project/node_modules/webpack/lib/Compilation.js:525:7) at Compiler.<anonymous> (/Users/romiem/my-project/node_modules/webpack/lib/Compiler.js:397:15) at /Users/romiem/my-project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:103:11 at /Users/romiem/my-project/node_modules/html-webpack-plugin/index.js:60:9 at tryCatcher (/Users/romiem/my-project/node_modules/html-webpack-plugin/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/Users/romiem/my-project/node_modules/html-webpack-plugin/node_modules/bluebird/js/release/promise.js:510:31) at Promise._settlePromise (/Users/romiem/my-project/node_modules/html-webpack-plugin/node_modules/bluebird/js/release/promise.js:567:18)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 10
  • Comments: 17 (6 by maintainers)

Most upvoted comments

After some more research, this only occurs for me when the allowJs flag is set to true in my tsconfig.json file.

Also, it is reproduced with 2.9.1 and with enabled resolveJsonModule compiler option.

If some of you are still following this I created an issue with ts-loader about this (in 2.9.1 with resolveJsonModule): https://github.com/TypeStrong/ts-loader/issues/793

I’m receiving this error with typescript 2.4.1

same here 😦

@timocov I tried upgrading my project to 2.9.1 to try this flag, and I also experience the issue when using the resolveJsonModule flag

I am receiving this with typescript: 2.8.1 ts-loader: 4.2.0 webpack: 4.5.0 webpack-cli: 2.0.14