-
Notifications
You must be signed in to change notification settings - Fork 21
toJavaScript() throws "Cannot read property 'text' of undefined" error on Windows #37
Comments
Changed issue title to make it clearer. |
toJavaScript()
throws "Cannot read property 'text' of undefined" error on Windows
toJavaScript()
throws "Cannot read property 'text' of undefined" error on Windows
Thank you for reporting! |
I still found this error in v5.0.2, in espower-typescript. But it is caused by another reason. When a file is imported by an entry file, its full path is used in |
@HerringtonDarkholme please give me PoC source code to reproduce or PR to resolve. |
I found this issue too in v5.0.2. My case is really weird because I have two different projects that are configured exactly the same but the error only appears on one of them. I'll try to debug it. In my case, I have a folder called test and a file called test.ts under test. My tsconfig.json looks like this:
The problem I found is that the output of
And the value of the variable I created a minimum project that reproduces the issue in Windows and OSX: alejo90/typescript-simple-bug. |
toJavaScript()
throws "Cannot read property 'text' of undefined" error on Windows.The typescript-simple uses
path.join
to join paths while Typescript doesn't. This difference causes following error intoJavaScript()
on Windows.On Windows,
outputFileName
is backslash separated path (foo\bar.ts)file.name
is slash separated path (foo/bar.ts).Thus
filter
returns an empty array andfile
is undefined.Then accessing
file.text
causes "Cannot read property 'text' of undefined" error.Following workaround works for me though I'm not sure this workaround is appropriate.
ts.normalizeSlahes
replaces\
with/
(https://github.com/Microsoft/TypeScript/blob/master/src/compiler/core.ts#L586).The text was updated successfully, but these errors were encountered: