Can I develop Node.js (Express) app in both JavaScript and TypeScript together?

October 22, 2019, at 11:20 PM

I have Node.js project (Express REST API) written in JavaScript. We decided to rewrite whole project to TypeScript. Is possible to do it slowly, part by part, but still be able to start server? I want rewrite just some parts so project will be partly JS partly TS. Is it possible?

Does ts-node-dev compile ts and ignore js?

Answer 1

Yes this should be possible based on a main principle of TypeScript: TS is a superset of JS and all JS is also legal TS.

If you want to be particularly granular in how you are migrating your project, you should configure the TS compiler to only pay attention to files in which you are implementing the change from JS to TS.

Answer 2

It's possible to do that, this kind of operation is called Migrating javascript to typescript, but if you tend to keep it half JS and half TS then it's logically wrong, because Typescript is transpiled : translated and compiled into java script, in a machinery coded manner. so having java script code with ts is basically not a good practice. You can allow js by the using the compiler flag --allowJs.

thus I think this post has more illustration.

Account Linking response for Actions On Google not correct in Hindi

Account Linking response for Actions On Google not correct in Hindi

I am making custom Google Action and in my app I am using account linkingThe response for when Google asks the user for confirmation in English is Correct but the same in Hindi is not

Mongoose ValidationError (Path is required)

Mongoose ValidationError (Path is required)

i am trying to write a post method in express

MongoDB Document Migrations

MongoDB Document Migrations

We currently version our document "schemas" using a __schemaVersion stored against a given document eg: