cevek / ttypescript

Over TypeScript tool to use custom transformers in the tsconfig.json
1.53k stars 56 forks source link

-w (watch) flag throws a TypeError #50

Closed amaschas closed 5 years ago

amaschas commented 5 years ago

I've tested this in v1.5.6 and v1.5.5. I run the ttsc transpiler via ttsc -w, and any code changes cause the transpiler to throw TypeError: Cannot read property 'text' of undefined. I've tested the same codebase with vanilla TypeScript and it transpiles without errors with the watch flag. Note that the code transpiles fine in the first run, it's the retranspilation that throw the error. Complete output below:

> ttsc -w
[3:28:09 PM] Starting compilation in watch mode...

[3:28:17 PM] Found 0 errors. Watching for file changes.
[3:28:20 PM] File change detected. Starting incremental compilation...

<project_dir_path>/node_modules/typescript/lib/typescript.js:89079
                throw e;
                ^

TypeError: Cannot read property 'text' of undefined
    at getErrorSpanForNode (<project_dir_path>/node_modules/typescript/lib/typescript.js:9187:40)
    at createDiagnosticForNodeInSourceFile (<project_dir_path>/node_modules/typescript/lib/typescript.js:9108:20)
    at Object.createDiagnosticForNode (<project_dir_path>/node_modules/typescript/lib/typescript.js:9099:16)
    at error (<project_dir_path>/node_modules/typescript/lib/typescript.js:31814:22)
    at resolveExternalModule (<project_dir_path>/node_modules/typescript/lib/typescript.js:33288:25)
    at resolveExternalModuleNameWorker (<project_dir_path>/node_modules/typescript/lib/typescript.js:33210:19)
    at resolveExternalModuleName (<project_dir_path>/node_modules/typescript/lib/typescript.js:33205:20)
    at checkImportDeclaration (<project_dir_path>/node_modules/typescript/lib/typescript.js:57055:49)
    at checkSourceElementWorker (<project_dir_path>/node_modules/typescript/lib/typescript.js:57412:28)
    at checkSourceElement (<project_dir_path>/node_modules/typescript/lib/typescript.js:57256:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <project_name>@0.0.1 build:ts:dev: `ttsc -w`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <project_name>@0.0.1 build:ts:dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     <user_dir_path>/.npm/_logs/2019-04-26T19_28_20_911Z-debug.log
cevek commented 5 years ago

Do you use any transformer?

amaschas commented 5 years ago

Ah yes, I do use ts-transformer-imports. That may very well be the problem, let me explore. Thanks!

zerkalica commented 5 years ago

@amaschas You can check analog https://github.com/zerkalica/zerollup/tree/master/packages/ts-transform-paths. probably, i fix something about watch mode (https://github.com/zerkalica/zerollup/issues/12) recently.

amaschas commented 5 years ago

Thanks, that one works fine with the -w flag. I'll report the issue on the ts-transformer-imports github.