TypeStrong / grunt-ts

A grunt task to manage your complete typescript development to production workflow
https://www.npmjs.com/package/grunt-ts
MIT License
330 stars 121 forks source link

TypeError: Cannot read property '_writeln' of undefined #418

Closed Erikvv closed 6 years ago

Erikvv commented 6 years ago
Running "ts:default" (ts) task
{ '0': 'File: \u001b[33m[no files]\u001b[39m' }
{ '0': 'Resolved exclude from tsconfig: ["!/home/erik/projects/wieluitlijning/node_modules/**"]' }
TypeError: Cannot read property '_writeln' of undefined
  at Log.writeln (/home/erik/projects/wieluitlijning/node_modules/grunt-legacy-log/index.js:178:8)
  at addFilesToCompilationContext (/home/erik/projects/wieluitlijning/node_modules/grunt-ts/tasks/modules/tsconfig.js:349:9)
  at applyCompilerOptions (/home/erik/projects/wieluitlijning/node_modules/grunt-ts/tasks/modules/tsconfig.js:329:14)
  at /home/erik/projects/wieluitlijning/node_modules/grunt-ts/tasks/modules/tsconfig.js:115:23
  at invokeResolver (/home/erik/projects/wieluitlijning/node_modules/grunt-ts/node_modules/es6-promise/dist/commonjs/promise/promise.js:42:5)
  at new Promise (/home/erik/projects/wieluitlijning/node_modules/grunt-ts/node_modules/es6-promise/dist/commonjs/promise/promise.js:29:3)
  at Object.resolveAsync (/home/erik/projects/wieluitlijning/node_modules/grunt-ts/tasks/modules/tsconfig.js:26:12)
  at /home/erik/projects/wieluitlijning/node_modules/grunt-ts/tasks/modules/optionsResolver.js:139:24
  at invokeCallback (/home/erik/projects/wieluitlijning/node_modules/grunt-ts/node_modules/es6-promise/dist/commonjs/promise/promise.js:54:15)
  at publish (/home/erik/projects/wieluitlijning/node_modules/grunt-ts/node_modules/es6-promise/dist/commonjs/promise/promise.js:99:5)
  at publishFulfillment (/home/erik/projects/wieluitlijning/node_modules/grunt-ts/node_modules/es6-promise/dist/commonjs/promise/promise.js:206:3)
  at flush (/home/erik/projects/wieluitlijning/node_modules/grunt-ts/node_modules/es6-promise/dist/commonjs/promise/asap.js:35:5)
  at process._tickCallback (internal/process/next_tick.js:150:11)
  at Function.Module.runMain (module.js:703:11)
  at startup (bootstrap_node.js:193:16)
  at bootstrap_node.js:617:3

{ '0': '\u001b[31mtsconfig error: Cannot read property \'_writeln\' of undefined\u001b[39m' }
tsconfig error: Cannot read property '_writeln' of undefined
{ '0': '\u001b[33mWarning: Task "ts:default" failed.\u0007 Use --force to continue.\u001b[39m' }
Warning: Task "ts:default" failed. Use --force to continue.

version: 6.0.0-beta.17

Log.prototype.writeln works in general but it seems like the "this" context is wrong in this case.

Erikvv commented 6 years ago

If I modify this line it works: https://github.com/TypeStrong/grunt-ts/blob/master/tasks/ts.ts#L52

replace grunt.log.verbose.writeln with (..args) => grunt.log.verbose.writeln(...args)

Not sure if this issue should be fixed in grunt-ts or in grunt itself.

nycdotnet commented 6 years ago

What version of grunt are you using? Can you share more of your gruntfile and any switches you're using on grunt?

Not sure why this would be a concern here. I haven't heard other reports of this being a problem.

nycdotnet commented 6 years ago

@Erikvv any chance you can provide the version of grunt/node you're using or did this cease being a problem?

Erikvv commented 6 years ago

I didn't solve the problem so I now run tsc as an npm task via grunt-exec.

I was using grunt 1.0.1 and node 9 which were the latest versions at the time.

Erikvv commented 6 years ago

Oh yeah it may be of note that the project uses a wrapper for grunt to split up the config file. But it works fine for a dozen other popular grunt tasks like webpack, linters and test frameworks.

Sorry for being semi-usefull, we don't use Grunt any more for newer projects and it's not worth it for me to spend time on this issue. Just wanted to share my experience so it may be of help.

nycdotnet commented 6 years ago

Totally understood - thanks so much for the report and sorry it took so long to reply. I am in a similar place with Grunt and it seems you had a special use-case. I'm maintaining grunt-ts mainly because of the long tail of users and I can't imagine we get many new users these days. Going to close this out, I think. Thank you!