DEV Community

Discussion on: ES6 is the Node way to go

Collapse
 
mohdahmad1 profile image
Mohd Ahmad

but, typescript guarantees type safety and rich intellisense, if you dont like typescript check JSDoc. JSDoc provides typings using regular JS comments so, no need for build steps.

examples

/** @type {(string|Array.)} */
var foo;

/** @type {number} */
var bar = 1;

/**
 * Represents a book.
 * @constructor
 * @param {string} title - The title of the book.
 * @param {string} author - The author of the book.
 */
function Book(title, author) {
   // your code
}
Enter fullscreen mode Exit fullscreen mode

it enhances intellisense of your code editor.
Visit for more Info

Thread Thread
 
w3nl profile image
Pieter Epeüs Wigboldus

JSDoc is indeed very useful for development, it's a standard for me to use it, but it's also not for runtime checking.

I made e.g. npmjs.com/package/@hckrnews/objects for type checking, but there are more packages to guarantee if the data is valid.
Typescript has some nice features, but for me there are also reasons I don't use it for node.js, and I found ways to write clean code that also guarantee that the data is valid.

Clean readable code, strict linting and good tests are very important for me.
For some it can be with typescript, but typescript don't guarantee that your code is good.
Use it if you like it, but it's not the holy grail for good code.