This repository was archived by the owner on Sep 21, 2019. It is now read-only.
This repository was archived by the owner on Sep 21, 2019. It is now read-only.
Failed to parse JS file #31
Closed
Description
Steps to reproduce:
1)Installed package and tried either CLI and VSCode version in windows 10 pro
2)Tried adding typescript and tslint globally.
3)Tested with and without tsconfig file
Expected output:
Convert the react file and produce a tsx file with the appropriate changes
Actual output:
Failed to convert ./summary.js
TypeError: Cannot read property 'kind' of undefined
at Object.isSourceFile (C:\Users\cyber\AppData\Roaming\npm\node_modules\react-js-to-ts\node_modules\typescript\lib\typescript.js:11833:20)
at Object.printNode (C:\Users\cyber\AppData\Roaming\npm\node_modules\react-js-to-ts\node_modules\typescript\lib\typescript.js:68607:40)
at Object.compile (C:\Users\cyber\AppData\Roaming\npm\node_modules\react-js-to-ts\dist\compiler.js:39:27)
at Object.run (C:\Users\cyber\AppData\Roaming\npm\node_modules\react-js-to-ts\dist\index.js:34:23)
at Command.<anonymous> (C:\Users\cyber\AppData\Roaming\npm\node_modules\react-js-to-ts\dist\cli.js:46:29)
at Command.listener (C:\Users\cyber\AppData\Roaming\npm\node_modules\react-js-to-ts\node_modules\commander\index.js:315:8)
at emitOne (events.js:115:13)
at Command.emit (events.js:210:7)
at Command.parseArgs (C:\Users\cyber\AppData\Roaming\npm\node_modules\react-js-to-ts\node_modules\commander\index.js:655:12)
at Command.parse (C:\Users\cyber\AppData\Roaming\npm\node_modules\react-js-to-ts\node_modules\commander\index.js:475:21)
at Object.<anonymous> (C:\Users\cyber\AppData\Roaming\npm\node_modules\react-js-to-ts\dist\cli.js:55:9)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
The file is created as .tsx but no changes to the file are made.
Activity
mohsen1 commentedon Jan 24, 2018
Can you paste your Javascript file's contents?
Duskfall commentedon Jan 25, 2018
mohsen1 commentedon Jan 25, 2018
@Duskfall Is the output here your desired output?
#32
Duskfall commentedon Jan 26, 2018
Exactly!
mohsen1 commentedon Jan 26, 2018
so core is working fine. Maybe there was an issue in CLI. I'll look into it
Duskfall commentedon Jan 29, 2018
On Ubunu 16.04 , it works only per file (glob doesn't work)
GeeWee commentedon Mar 11, 2018
I get the same issue:
Sample jsx file:
(Note this file is with esModuleInterop enabled, hence the React import looking like it does. I have also tested without.
cdiggins commentedon Apr 9, 2018
@mohsen1 : We are running into this same problem as well. How did you run "core" to get it to work?
EDIT: Works like a charm on Mac, Windows fails even on the example on the home page. Had some trouble on Mac with the globbing though.
mohsen1 commentedon Apr 9, 2018
@cdiggins You can use the CLI
https://github.com/lyft/react-javascript-to-typescript-transform#cli
Also, if you can provide us with a file that didn't work I would appreciate it.
benoxoft commentedon Apr 9, 2018
I had the same problem as @Duskfall on macOS (glob doesn't work) so I used this command to convert every jsx files we had:
mohsen1 commentedon Apr 9, 2018
So CLI is broken for sure
#37
reflog commentedon Apr 26, 2018
same here. both cli and vscode extension are broken
mediaslav commentedon May 8, 2018
problem is here https://github.com/lyft/react-javascript-to-typescript-transform/blob/master/src/compiler.ts#L29
filenames can have various separators and case, so equality don't work here, it needs fileName.replace(/[/\]/g, path.sep).toUpperCase() for both parts atleast on Windows
AnthonyZavala commentedon May 17, 2018
@mediaslav That's the problem I was seeing. Replacing '\' with '/' in the file path fixes the issue.
Fix multiple file/glob parameters
Safety/QOL fixes (#39)
caleb15 commentedon Jun 19, 2019
I'm getting the same problem on windows 10 with latest version of npm package.
smeijer commentedon Jun 23, 2019
This library looks o promising to help us migrate from js to typescript. But it doesn't work.
Not with glob, but also not by specifying a direct, single file.
dschaller commentedon Sep 20, 2019
Thank you for you contribution to this repository.
Closing this contribution as this repository is being archived.