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
-
@nasuke because now object is restricted to type Type, which hopefully provides reliable guarantees about it's functionally, so you don't have to bend over backwards to ensure those guarantees every time you use the object.
-
We use TS quite extensively in my company and it helps to catch many type and logical errors on transpile time.
You can do this is js:
function multi(a, b) {
return a * b;
}
// you don't want this to be allowed...
mult(1,'abc');
In TS you can forbid this usage by using types:
function mult( a:number, b:number) : number {
return a * b;
}
// now this peoduces a type error
mult(1,'abc'); -
Please provide your arguments as to why it makes things complex, also, have you ever worked with other type-safe languages like Java, c# or even lower?
-
C0D4669025yGo learn Java then come back to JavaScript.
This is why typescript exists, to bring backend type safety to a frontend language that doesn't have it.
Outside of that, yes it's an added layer of JS that I don't use, as I am more then capable of looking up a function and seeing what it does and doesn't accept, and then not calling multi() with a string in it as @adifferent's example is doing calculations. -
nasuke135y@alexbrooklyn yes, my first language was Java, I admit struggled at the beggining with Javascript, but when i understood how it worked, everything was easier.
To me TS is like going back to Java again.
My point with TS been adding complexity is that the code is harder to read.
Edit: just like @C0D4 said, I found easier to just look at what a function accepts and work from there -
@C0D4 I hope this will work out for you!
For me and my company it's not so we switched to ts. I like the comfort and safety typescript provides when using it correctly..
We develop a complex web frontend applications using react, xstate etc. and typescript provides a good (but not perfect) way to implement features faster, makes refactoring more safe and easygoing and enables a faster onboarding of new developers.
It simply adds huge business value.
We also get advanced intellisense and documentation of types on top. -
@nasuke You're obviously thinking as a lone dev with his own source code.
Try thinking of a large dev team where one dev modifies a function (refactoring and shit) without being aware that someone else had been using it in a certain way, and BAMM you have a runtime misbehaviour that will be hard to catch. With proper types, that would have been spotted at compile time.
Means, NO debugging time (expensive), NO looking through the whole codebase (also expensive). -
olback107945yTypescript makes Javascript readable. Looking at JS source on github I have no idea what's going on since there's no way to know what data/type something returns. Typescript solves all of this.
Related Rants
Why the FUCK typescript exists? it solves NOTHING, it just adds more complexity to the code
question
typescript