re: Get Started With TypeScript in 2019 VIEW POST


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:

// hello.ts
function hello() {

module.exports = {

// index.ts
const {hello} = require('./hello');


JS version works as expected, but TS throws

error TS2451: Cannot redeclare block-scoped variable 'hello'.

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.

Code of Conduct Report abuse