fork-ts-checker-webpack-plugin: TypeError: Cannot read property '0' of undefined
The plugin crashed right after rebuilding (in watch mode), with below message
/~/node_modules/fork-ts-checker-webpack-plugin/lib/index.js:323
var elapsed = Math.round(_this.elapsed[0] * 1E9 + _this.elapsed[1]);
^
TypeError: Cannot read property '0' of undefined
at ForkTsCheckerWebpackPlugin.doneCallback (~node_modules/fork-ts-checker-webpack-plugin/lib/index.js:323:51)
at ForkTsCheckerWebpackPlugin.handleServiceMessage (/~/node_modules/fork-ts-checker-webpack-plugin/lib/index.js:273:52)
at ChildProcess.<anonymous> (/Users/rok/GitHub/sinicompany/closer-www/node_modules/fork-ts-checker-webpack-plugin/lib/index.js:231:70)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at emit (internal/child_process.js:772:12)
at _combinedTickCallback (internal/process/next_tick.js:141:11)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
version
webpack 3.8.1 webpack-dev-server 2.9.4 fork-ts-checker-plugin 0.2.9 typescirpt 2.6.1 tslint 5.8.0 tslint-microsoft-contrib 5.0.1
options
fork-ts-checker-plugin
{
"tsconfig": "../tsconfig.json",
"tslint": "../tslint.json",
"checkSyntacticErrors": true,
}
tsconfig
{
"compilerOptions": {
"sourceMap": true,
"target": "es5",
"jsx": "react",
"module": "esnext",
"moduleResolution": "node",
"allowJs": false,
"importHelpers": true,
"emitDecoratorMetadata": false,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"downlevelIteration": true,
"pretty": true,
"declaration": false,
"noUnusedLocals": true,
"noUnusedParameters": false,
"noImplicitAny": false,
"noImplicitReturns": false,
"removeComments": false,
"strictNullChecks": false,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"*": ["src/*", "*"]
},
"lib": [
"es6",
"es7",
"dom"
]
},
"exclude": [
"dist",
"node_modules"
]
}
tslint
{
"rulesDirectory": [
"node_modules/tslint-microsoft-contrib"
],
...
}
it works well with fork-ts-checker-plugin@0.2.8
.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 5
- Comments: 20 (10 by maintainers)
Commits related to this issue
- Merge pull request #82 from johnnyreilly/master fix for #76 — committed to TypeStrong/fork-ts-checker-webpack-plugin by piotr-oles 7 years ago
@johnnyreilly I’m using the Chrome inspector to walk through some of the code. It looks like
this.elapsed
is initially set. However, whencreateDoneCallback()
is called,elapsed
is not defined. In other words,handleServiceMessage()
is called aftercreateDoneCallback()
and I believe after a child process is spun off.handleServiceMessage()
does defineelapsed
onthis
, but_this
increateDoneCallback()
is never updated.Presumably,
createDoneCallback()
's_this
andhandleServiceMessage()
'sthis
refer to differentthis
objects. I wonder if that has anything to do withchild-process
. PerhapshandleServiceMessage()
is being called in a child process and not modifying the samethis
?However,
this
does haveelapsed
defined within the done callback defined bycreateDoneCallback()
(but not_this
).The solution I found was to use
this
instead of_this
in the callback created bycreateDoneCallback()
.Great - I’ll submit a PR. Thanks!