Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
It IS better, because you don't infer what's it going to return - you straight up tell devs to prevent/extend dependency on what function shall return.
Also, pissing on type-safe arguments in 2022 be like...
Alright "err: any" is very ugly - but that's because it doesn't commit anything good to DX. -
it obviously is.
however, both are equally inferior to an _actual_ strongly typed language. (TS, in the end, is just JS with extra steps) -
Voxera113883yHaving worked with every version of javascript since 1.0 in netscape 2 I live the explicit types.
Sure, for 10 likes it looks more convoluted but when your in the thousands of lines from a dozen developers those types along with intellisense and linting helps immensely to prevent bugs.
And with type inference you often end up not needing to specify the types all that much and you get all the benefits.
But especially intellisense gets a lot more powerful with real typing. -
Voxera113883y@PonySlaystation no, but that is not typescript vs js differences.
Just because a dev writes bad code in a language is not necessarily the fault of the language.
That example was not really good TS code so I focused on the actual TS specific differences. -
@PonySlaystation Sure, there are subtle differences... which don't matter in the non-freak lambda use cases.
-
a(data => {
console.log(data)
})
a("some_stuff", (err, data) => {
console.log(data)
})
a((err, data) => {
if (data.done)
console.log(data.result)
})
Related Rants
WHO THE FUCK THINKS
THIS SHIT
TS:
```
const a = function(callback: (err:any,data:string) => void):void{
callback(null,'balls');
}
a(function(err:any,data:string){
console.log(err,data)
})
```
IS BETTER THAN THIS
ES6:
```
const a = function(callback){
callback(null,'balls');
}
a(function(err,data){
console.log(err,data)
})
```
kys
devrant
rant
typescript