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)
same here :(
+1
experiencing this same issue as well
+1
I initially fought it was a duplicate of #13004 but it is NOT. This issue is till present with [email protected]
It seems to be related though because if I change the import from the node module import 'normalize.css'; to a file in the node module import 'normalize.css/normalize.css'; it solves the issue.
I have a fix up in https://github.com/Microsoft/TypeScript/pull/13136
The fix should be in [email protected] (some time after midnight). Please give it a try and let us know if the issue is still there.
I'm receiving this error with typescript 2.4.1
I am receiving this with
typescript: 2.8.1
ts-loader: 4.2.0
webpack: 4.5.0
webpack-cli: 2.0.14
I am also receiving this with:
typescript: 2.8.3
ts-loader: 4.2.0
webpack: 4.6.0
webpack-cli: 2.0.14
EDIT 1: more research
After some more research, this only occurs for me when the allowJs flag is set to true in my tsconfig.json file.
EDIT 2: stacktrace
C:\devl\repo\test\node_modules\typescript\lib\typescript.js:103359
return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken));
^
TypeError: Cannot read property 'getOptionsDiagnostics' of undefined
at Object.getCompilerOptionsDiagnostics (C:\devl\repo\test\node_modules\typescript\lib\typescript.js:103359:27)
at provideCompilerOptionDiagnosticErrorsToWebpack (C:\devl\repo\test\node_modules\ts-loader\dist\after-compile.js:39:31)
at C:\devl\repo\test\node_modules\ts-loader\dist\after-compile.js:17:9
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\devl\repo\test\node_modules\tapable\lib\HookCodeFactory.js:50:10), <anonymous>:16:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (C:\devl\repo\test\node_modules\tapable\lib\Hook.js:35:21)
at compilation.seal.err (C:\devl\repo\test\node_modules\webpack\lib\Compiler.js:484:30)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\devl\repo\test\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (C:\devl\repo\test\node_modules\tapable\lib\Hook.js:35:21)
at hooks.optimizeAssets.callAsync.err (C:\devl\repo\test\node_modules\webpack\lib\Compilation.js:966:35)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\devl\repo\test\node_modules\tapable\lib\HookCodeFactory.js:50:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (C:\devl\repo\test\node_modules\tapable\lib\Hook.js:35:21)
at hooks.optimizeChunkAssets.callAsync.err (C:\devl\repo\test\node_modules\webpack\lib\Compilation.js:957:32)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\devl\repo\test\node_modules\tapable\lib\HookCodeFactory.js:50:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (C:\devl\repo\test\node_modules\tapable\lib\Hook.js:35:21)
at hooks.additionalAssets.callAsync.err (C:\devl\repo\test\node_modules\webpack\lib\Compilation.js:952:36)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\devl\repo\test\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (C:\devl\repo\test\node_modules\tapable\lib\Hook.js:35:21)
at hooks.optimizeTree.callAsync.err (C:\devl\repo\test\node_modules\webpack\lib\Compilation.js:948:32)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\devl\repo\test\node_modules\tapable\lib\HookCodeFactory.js:50:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (C:\devl\repo\test\node_modules\tapable\lib\Hook.js:35:21)
at Compilation.seal (C:\devl\repo\test\node_modules\webpack\lib\Compilation.js:890:27)
at hooks.make.callAsync.err (C:\devl\repo\test\node_modules\webpack\lib\Compiler.js:481:17)
at _done (eval at create (C:\devl\repo\test\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:9:1)
at _err1 (eval at create (C:\devl\repo\test\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:32:22)
at _addModuleChain (C:\devl\repo\test\node_modules\webpack\lib\Compilation.js:758:12)
at processModuleDependencies.err (C:\devl\repo\test\node_modules\webpack\lib\Compilation.js:697:9)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
the error seems to be in provideCompilerOptionDiagnosticErrorsToWebpack (in the loader sources) accessing errors on an undefined program. mind filing this on https://github.com/TypeStrong/ts-loader/issues instead.
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.
@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
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 get the same error when "paths" object has invalid values (double asterisks instead single one) and "allowJs" is true:
{
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"paths": {
"@/**": ["client/**"]
}
}
}
(node:6560) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getOptionsDiagnostics' of undefined
at Object.getCompilerOptionsDiagnostics (C:\wip\racehub\node_modules\typescript\lib\typescript.js:115096:28)
at provideCompilerOptionDiagnosticErrorsToWebpack (C:\wip\racehub\node_modules\ts-loader\dist\after-compile.js:40:31)
at C:\wip\racehub\node_modules\ts-loader\dist\after-compile.js:17:9
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\wip\racehub\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:16:1)
at AsyncSeriesHook.lazyCompileHook (C:\wip\racehub\node_modules\tapable\lib\Hook.js:154:20)
at compilation.seal.err (C:\wip\racehub\node_modules\webpack\lib\Compiler.js:544:30)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\wip\racehub\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (C:\wip\racehub\node_modules\tapable\lib\Hook.js:154:20)
at hooks.optimizeAssets.callAsync.err (C:\wip\racehub\node_modules\webpack\lib\Compilation.js:1296:35)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\wip\racehub\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (C:\wip\racehub\node_modules\tapable\lib\Hook.js:154:20)
at hooks.optimizeChunkAssets.callAsync.err (C:\wip\racehub\node_modules\webpack\lib\Compilation.js:1287:32)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\wip\racehub\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (C:\wip\racehub\node_modules\tapable\lib\Hook.js:154:20)
at hooks.additionalAssets.callAsync.err (C:\wip\racehub\node_modules\webpack\lib\Compilation.js:1282:36)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\wip\racehub\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (C:\wip\racehub\node_modules\tapable\lib\Hook.js:154:20)
at hooks.optimizeTree.callAsync.err (C:\wip\racehub\node_modules\webpack\lib\Compilation.js:1278:32)
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\wip\racehub\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (C:\wip\racehub\node_modules\tapable\lib\Hook.js:154:20)
at Compilation.seal (C:\wip\racehub\node_modules\webpack\lib\Compilation.js:1215:27)
at hooks.make.callAsync.err (C:\wip\racehub\node_modules\webpack\lib\Compiler.js:541:17)
at _done (eval at create (C:\wip\racehub\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:9:1)
at _err0 (eval at create (C:\wip\racehub\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:20:22)
at childCompiler.compileTemplate.catch.then.compilationResult (C:\wip\racehub\node_modules\html-webpack-plugin\index.js:84:11)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:6560) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6560) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
If I remove "allowJs" field from tsconfig.json, then I get a real reason why it failed before:
ERROR in C:\wip\racehub\tsconfig.json
[tsl] ERROR
TS5061: Pattern '@/**' can have at most one '*' character.
ERROR in C:\wip\racehub\tsconfig.json
[tsl] ERROR
TS5062: Substitution 'client/**' in pattern '@/**' in can have at most one '*' character.
Most helpful comment
Also, it is reproduced with 2.9.1 and with enabled
resolveJsonModulecompiler option.