DEV Community

Discussion on: JS Functional Concepts: Pipe and Compose

 
wiseai profile image
Mahmoud Harmouch

Because the absence of types (nor TS nor JSDoc+TS Pragma ) leads sooner or later to non-expected paths that can break the app in runtime, which is a business problem that will rain as sh*t over the dev team

Yep. Although the absence of types may not be considered a major problem by some, me included, I believe that not following best practices is what ultimately causes more issues in web development. By adhering to established conventions and standards, we can avoid many of the potential problems that can occur without these guidelines. In addition, following best practices often leads to code that is easier to read and understand, which can save time and frustration for all parties involved.

But, the thing is that major business issues, even though I don't have data but from what I have experienced, are not necessarily caused by the absence of types. I think there is a correlation between the two. But, the relation is not causation. The absence of types doesn't necessarily lead to rain as sh*t over the dev team. Know what I am saying?

Are the types necessary in every single App? No, they aren't.

Agree.

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

Of course not, the main issue is not having tests.
Key in the discussion here being that coding in TypeScript is faster than vanilla JS + JSDoc + TS Pragma, you may never seen it this way but look:

/**
 * Sums two numbers
 * @param  {number} n1
 * @param  {number} n2
 * @returns {number}
 */
const sumTwoNumbers = (n1, n2) => n1+n2;
Enter fullscreen mode Exit fullscreen mode
/** Sums two numbers */
const sumTwoNumbers = (n1: number, n2: number) => n1+n2;
Enter fullscreen mode Exit fullscreen mode

As well as more reliable.
To get a similar reliability with JSDoc you need to ensure JSDoc is added and maintained through automatisms in the linter and run this step in the PR's pipeline, at least (i.e. ESLint plugin JSDoc) and it takes more to configure than what it takes to configure TS most of the time.

Keep in mind that using JSDoc and TSPragma you are just using one little piece of TS, which is about type definition and type reports (and it doesn't even cover it entirely).

If you just need those features, then add TS and just use those features 😂

Do you dislike interfaces? Fine, don't use them, if you are working in FP instead OOP, interfaces doesn't even make sense (in FP all functions are interfaces).

It is not mandatory to use everything from TS so don't stress it so hard 😁

Thread Thread
 
wiseai profile image
Mahmoud Harmouch

💯

Some comments have been hidden by the post's author - find out more