Thanks for the great article!
I'm new to TypeScript and couple of days ago I decided to convert my Node JS project to TS for better maintability. I heard many times that firts steps should be painless - just rename .js to .ts.
TypeScript allows you to easily convert a JavaScript file by changing the file extension from .js to .ts and all the code will compile properly as TypeScript.
Nevertheless, I faced couple of problems from the beginning.
Consider the most basic Node project:
I had to replace require to import across all project files to fix the issue.
Another problem popped up when I tried to compile TS files without types for 3rd party libraries.
Anyway, right now I'm in the middle of moving the project to TS and I feel much more confident with it's logic and data structures compared to the raw JS version.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the great article!
I'm new to TypeScript and couple of days ago I decided to convert my Node JS project to TS for better maintability. I heard many times that firts steps should be painless - just rename
.js
to.ts
.Nevertheless, I faced couple of problems from the beginning.
Consider the most basic Node project:
JS version works as expected, but TS throws
error TS2451: Cannot redeclare block-scoped variable 'hello'.
I had to replace
require
toimport
across all project files to fix the issue.Another problem popped up when I tried to compile TS files without types for 3rd party libraries.
Anyway, right now I'm in the middle of moving the project to TS and I feel much more confident with it's logic and data structures compared to the raw JS version.