1

Recently I was planning to translate my JavaScript-based Node project to Typescript. Then I got the news of Deno... It's amazing to have a runtime with native Typescript support!

But the question is, how to migrate the existing JavaScript-based project.

Some Experts pointed out, translating from JavaScript to TypeScript is not required for Deno! Thats OK, but I think it's better to translate, if the codebase is not that large.

Existing question has the answer for Typescript-based node project but I'm looking for a Javascript-based project.

DevLoverUmar
  • 11,809
  • 11
  • 68
  • 98
  • sounds horrible to me. Like saying my OS has a built in C++. Which would likely mean it's always behind the spec. Where as an unbundled language is not. – gman May 21 '20 at 04:09

2 Answers2

1

This link should give you what you're looking for.

It's fairly simple, all things considered.

First, you need to convert JavaScript into TypeScript. Information on that here.

Make sure to remove all .json stuff, such as package.json and package-lock.json. Remove all node modules.

Add .ts to all import statements.

After that, you're going to have to fix the parser rules and adapt to the different logic.

1

First of all: Deno supports both JavaScript & TypeScript. You don't need to migrate your code to TypeScript in order to move from Node.js to Deno.

With that in mind, there are other things to consider.

In another answer that I wrote I explained some key aspects when moving from Node to Deno.

Standard libraries

Your code (either JS or TS) will have to adapt to "Node specific" APIs that will be adapted for Deno.

Example:

// Node.js
require('fs').readFile('data.json');

// Deno
Deno.readFile('data.json')

Third Party libraries

The same principle for standard libraries apply for 3rd party modules.

You'll have to rewrite the integration with libs and frameworks.

Deno just launched

Node.js is a stabled and matured technology,

You'll not find the same amount of features and support available for Deno as in Node.js. Deno is still too young.


Migrating your own code from JavaScript to TypeScript shouldn't have any impact on Deno itself. For that you have to look elsewhere for guidance on how to best perform the language migration.

Evandro Pomatti
  • 13,341
  • 16
  • 97
  • 165