You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue describes the whole process ,because I think it's easier to understand that way instead of filing multiple small issues.
Initial state
I have one project where I all my javascript files are in src and they user extension mjs. My project also has jsconfig.json. This project does not have any dependencies. It's just run with command node src/index.mjs to do some dev tasks. It may not be very representative of common project that would be converted to Typescript like this.
Testing TypeStat for typescript migration. These were my answers
✔ What are you trying to accomplish? · Convert my JavaScript files to TypeScript
✔ Where is your tsconfig.json? · I don't have one yet
✔ Should TypeScript output .js files from .ts sources? · yes
✔ Does your code run in browser? · no
✔ Does your project use JSX? · no
✔ What minimum runtime does your code run on? · es2022
✔ Would you like to enable TypeScript's strict compiler options? (recommended) · yes
✔ Which glob matches files you'd like to convert? · other
✔ Which files would you like to convert? · src/**/*.mjs
✔ How would you like .js files to be renamed? · Rename all files to .ts
✔ Would you like imports without extensions to have those extensions added in? · No
✔ Would you like to suppress remaining type errors with // @ts-expect-error comments? · Yes
The only change that this did, is that it change filenames from ".mjs" to ".ts". This broke the code, because my imports were using ".mjs" endings 😬 And probably because of this, it couldn't fix incomplete types? It's though also possible that the incomplete types failed, because I had not installed typescript beforehand.
Feedback / questions / ideas
Should I have installed typescript first?
Could jsconfig.json be used to import some settings to tsconfig.json?
I'm not sure what "Should TypeScript output .js files from .ts sources?" means. I first thought it means renaming files, but I guess it means that should it emit js files. Now it feels silly that I did not understand it when reading first time.
The tool should handle project that uses .mjs extensions. Though I guess the imports should use ".js" and this is also user error?
Generated tsconfig.json has warning / error: "Option 'moduleResolution' must be set to 'NodeNext' (or left unspecified) when option 'module' is set to 'NodeNext'."
That said, I think I should try this again with next release to see, how it works when doing that.
(Annoyingly, I lost a file that had some secrets that were not saved anywhere due to user error. They were in another .mjs file that was not committed to git. And when I reverted the changes this tool did, I lost that file also. I guess lesson learned to not do that in future.)
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
main
branch of the repository.Expected
// omit
Actual
// omit
Additional Info
This issue describes the whole process ,because I think it's easier to understand that way instead of filing multiple small issues.
Initial state
I have one project where I all my javascript files are in
src
and they user extensionmjs
. My project also hasjsconfig.json
. This project does not have any dependencies. It's just run with commandnode src/index.mjs
to do some dev tasks. It may not be very representative of common project that would be converted to Typescript like this.Running first time
Testing
TypeStat
for typescript migration. These were my answersthe generated tsconfig.json looks like this
typestat.json
Changes made
The only change that this did, is that it change filenames from ".mjs" to ".ts". This broke the code, because my imports were using ".mjs" endings 😬 And probably because of this, it couldn't fix incomplete types? It's though also possible that the incomplete types failed, because I had not installed typescript beforehand.
Feedback / questions / ideas
That said, I think I should try this again with next release to see, how it works when doing that.
(Annoyingly, I lost a file that had some secrets that were not saved anywhere due to user error. They were in another .mjs file that was not committed to git. And when I reverted the changes this tool did, I lost that file also. I guess lesson learned to not do that in future.)
The text was updated successfully, but these errors were encountered: