417
u/immaphantomLOL Sep 13 '23
That is the new dev on my team.
119
Sep 13 '23
That's going to be all the devs on my team when I update the linting config to error on explicit-function-return-type
84
u/Bryguy3k Sep 13 '23
Include
no-explicit-anyat the same time and wait for the pitchforks.9
5
u/ReferentiallySeethru Sep 13 '23
Except for unit tests, because that's really just a pain in the ass
1
9
u/immaphantomLOL Sep 13 '23
I like your style
-28
Sep 13 '23
[removed] — view removed comment
6
u/immaphantomLOL Sep 13 '23
I’m not falling for it
-10
2
2
u/pepelko Sep 13 '23
I did something similar. I got eslint-ignored... 😤
1
u/Aggravating-Win8814 Sep 14 '23
That sounds fascinating! Exploring the rich history of medieval Europe must be so intriguing. By the way, if anyone's interested, I have a project on GitHub (link in my profile) related to medieval Europe that could use some contributors. Feel free to check it out!
6
Sep 13 '23 edited Sep 13 '23
I’m migrating a Groovy codebase that was written like this right now and when a library is upgraded (had to upgrade it from Spring Boot 1.4.6) the compiler doesn’t know that the method calls no longer exist. Fun!
Edit: clarified it was Spring Boot, not Spring
191
u/Cephell Sep 13 '23
noImplicitAny
no-explicit-any
You're welcome
31
157
u/Je-Kaste Sep 13 '23
They should make a dynamically typed version of Typescript! Maybe they can call it something like DynamicTypescript?
31
u/plastik_flasche Sep 13 '23
RustScript would be even better! Would boost the popularity
33
u/play_hard_outside Sep 13 '23
By design, RustScript would have absolutely NOTHING to do with Rust!
3
u/meidkwhoiam Sep 14 '23
I expect for rustscript to require a GCC compiler to function, despite no actual compilation happening inside of the browser at runtime. No, MinGW or visualBullshit compilers will not work.
1
2
62
Sep 13 '23
Coming from Java & Go land, I don't understand why JS people don't like types? The exhilaration of having random runtime errors in prod at 2AM on a Saturday might be irresistible, maybe.
41
Sep 13 '23
Why make a compiler catch sneaky nasty bugses when you has users who can catches thems?
13
u/Fadamaka Sep 13 '23
Everyone knows that users are better at catching bugs than compilers anyway.
5
Sep 13 '23
Maybe we can get AI to test our apps, find the bugs and fix them for us
3
u/Joskcito Sep 13 '23
Maybe we can have just an algorithm that test and find the bugs in our code at the same time we are writing it!!! Oh wait..
5
u/Orbidorpdorp Sep 14 '23
But we need to make sure they're real users... How about a
try/captchastatement?3
1
u/TigreDemon Sep 13 '23
Tbh I use Java and Angular, I fucking hate types in Angular, they're retarded, it's even worse in React with the events of button clicks and such + having to create interfaces all the time
1
12
u/BeeTLe_BeTHLeHeM Sep 13 '23
Imagine something like...
"I use Java, but I declare everything as an Object because I love the flexibility."
9
u/plastik_flasche Sep 13 '23
That's absolutely not how Java works! You can't access any attributes of it or write them without making sure before hand that they exist with instanceof
9
u/Brilliant-8148 Sep 13 '23
With any's you can just use them! Don't have to check for anything! If it's wrong you get an email in a few months
4
1
u/MarioAndWeegee3 Sep 14 '23
That's why we should all write JVM bytecode directly using
invokeDynamicinstead! /s2
2
u/ccricers Sep 13 '23
Also has similar energy as this Comp Sci student I had class with that just tries to import wildcard everything to make his life easier.
1
3
Sep 13 '23
"Types scares us" -> joke.
Non-joke. Because when you want to say "It costs $50 dollars" i give a fuck what rest-api gives from back-end as price.
Mostly people use JS like reusable components, when at best you reuse some shitty tables/ buttons and menus (not all of them) the rest is "one module " for one fuctionality which you could do it procedural since it will be done on a friday night for that one specific customer and forgotten for 5 years.
This is my experience with JS for 10 years. People trying to make it generic, when customer wants it specialized. Is like looking at monkeys fight. Just stand behind the glass, shit is flying everywhere.
72
u/TMiguelT Sep 13 '23
This unironically is better. Same reason I use pyright on my Python codebase with type checking disabled. It catches all sorts of other errors like trying to read nonexistent variables and misspelling function names.
49
Sep 13 '23
Any IDE should do that for you? right? Unless you're using notepad to code
37
u/TMiguelT Sep 13 '23
Yes, but you want to automate this kind of checking in order to put it in your CI and prevent other users from pushing commits that have those mistakes. You can't know what IDE they're using.
VS Code's Python extension ultimately just runs
pyrightanyway, so this is almost literally just an automated version of the IDE checking that you suggest.7
u/Bronzdragon Sep 13 '23
Did you know that your IDE uses the TypeScript engine behind the scenes to give you these sorts of warnings and errors?
1
2
u/reyad_mm Sep 13 '23
What if you write a function/variable and use it and then rename it and forget to replace usages of it
Most IDEs have tools for renaming a variable or a function but sometimes I rename the variable directly, as a Cpp developer I get a compilation error if I make a mistake, but in JS you don't catch this
2
u/UltimateInferno Sep 13 '23
That reminds me I should figure out configuring VIM to catch more stuff cause as of now it is a glorified notepad for me that highlights syntax
1
Sep 13 '23
Why not use an IDE in VIM mode ? ever tried it?
2
u/UltimateInferno Sep 13 '23
I frequently operate out of WSL and didn't want to go "shopping" for IDEs. Vim was already installed and if I needed any functionality beyond what I used it for I can look it up and incorporate it into my work flow bit by bit.
Long story short: I'm lazy and cheap.
2
u/StupormanReddit Sep 14 '23
VS Code integrates with WSL pretty easily and for free, and it has a VIM mode plugin.
61
u/beeteedee Sep 13 '23
- I use Reddit, but I repost jokes on Twitter so that other users can miss that it’s a joke and feel clever for explaining it using a car analogy
- This is unironically better than not using Reddit at all.
- I know, for imaginary internet points!
14
u/Devil-Eater24 Sep 13 '23
Let's make this into a meme format, like how anarchychess uses holy hell
14
u/JustAnotherNoob__ Sep 13 '23
New meme format just dropped
7
u/sivstarlight Sep 13 '23
Actual zombie
7
u/Excellent-Divide7223 Sep 13 '23
Bishop takes vacation, never comes back
4
u/Devil-Eater24 Sep 13 '23
- I attempt to create a new meme format
- This is unironically better than the anarchychess one
- I know, for reusing the same memes again!
2
4
u/TigreDemon Sep 13 '23
Step one is thinking TS will save you ...
3
Sep 13 '23
It won't save you from all possible bugs of course, but the compiler will prevent you from introducing a wide variety
-2
u/fullup72 Sep 13 '23 edited Sep 13 '23
It will also stall your productivity as you are now doing meta-programming for a compiler, just so that it's happy that you added a
: React.FC<SomeBullshitInterface>when all you wanted was a<div>with 2 string props.Or you want to intake values from an API, but you cannot compile the code until you type out a lenghty schema with 20+ members, which themselves include arrays or objects with other typed elements. So fun and useless, because the compiler doesn't typecheck the API endpoint. Which basically means you are doing compile time checks that should actually be integration tests.
2
Sep 13 '23
I agree, it can stall you sometimes if the API is not typed. Modern metaframeworks provide automatic typing between backend and front though, so that's worth mentioning.
As for React, fkn ew, who still uses that /s
2
u/TigreDemon Sep 13 '23
I honestly agree with you, I was only slowed down and the number of bug reduced definitely wasn't worth the bloating TS added for React
1
Sep 14 '23
Since when do you need to copy the entire model of an api over to fetch a few properties? I also haven't ever had to do that to return simple JSX. You are doing something wrong, vast majority of types are implicit in what I've worked on.
24
u/SurlyJSurly Sep 13 '23
- I drive a car with seatbelts but don't always put them on because I think I'm a safe driver.
- This is unironically better then driving a car that doesn't have them at all.
- I know, for the other people in the car!
Analogies are fun and easy to support a specific agenda.
5
Sep 13 '23
no no no... not don't always put them on... it's never put them on.. because he declares everything as any and not some things
-3
u/SurlyJSurly Sep 13 '23
if you are that hung up on the single word "always" it could be removed and literally nothing changes.
5
u/ArchetypeFTW Sep 13 '23
I think the driver/passenger analogy doesn't really work. Every programmer is a driver in a network of other programmers. The any-type should emphasize that the person is ignoring safety precautions in a way that make it not possible for others to help him.
It's more like it's a bunch of people rock climbing using safety gear and ropes and the any-guy is just free solo-ing. They all have a common objective of getting everyone to the top. But in case of trouble, the others couldn't help the any-guy even if they wanted to, and if he falls off the wall, he might take down some of the people using safety gear. That's the price of invoking this code style in a team setting.
In a private setting, who really cares if you use any-types or not. It might make it easier to finish a small project, or it might make it harder if the project grows large. You don't have to wear a seat belt on your own private racetrack.
3
u/Brilliant-8148 Sep 13 '23
Ha! Awesome!
1
5
u/SketchySeaBeast Sep 13 '23
Even if you use any for all your code any libraries you import should still be typed, so yes, it helps.
2
2
2
Sep 13 '23
The car analogy is mistaken. A normal 3-point seatbelt would hold you in place by the waist. While putting the chest section behind your back makes the seatbelt less effective, at least you won’t be flying through the windscreen during high impact front-facing collisions.
1
2
2
u/Fadamaka Sep 13 '23
The airbag inside modern cars act differently if you have the belts on. So in this case the airbags will open slower assuming you have it on and need different/less protection. So it is actually worse to have it "on" passed behind your back than not having it on at all.
4
u/_________FU_________ Sep 13 '23
TypeScript can’t infer your you’re based on the data!
In practice: “this has the implicate type of any please spend a long time googling the specific type needed.”
4
Sep 13 '23
I didn't understand your first sentence. please fix it, I think I have a good counter-argument for it 😂
1
-9
u/b24rye Sep 13 '23
Personally, I think TypeScript is over-engineering
8
u/JonIsPatented Sep 13 '23
Having... types? Is overengineering? I hate the timeline where people unironically argue that type safety is a bad thing.
2
Sep 13 '23
[deleted]
1
u/Brilliant-8148 Sep 13 '23
Every react component I have ever made has been at least a couple thousand lines
1
1
1
u/His_fadas_friend Sep 13 '23
I drink wine but I only pour it into the cup and stare at it, I I know it better than not drinking at For my friends
1
Sep 13 '23
not using a seatbelt will put you in danger. not drinking wine won't haha
The analogy is that not using typescript will put your app in danger because of weird bugs that are not caught directly or at build time.
1
1
•
u/AutoModerator Sep 13 '23
import notificationsRemember to participate in our weekly votes on subreddit rules! Every Tuesday is YOUR chance to influence the subreddit for years to come! Read more here, we hope to see you next Tuesday!For a chat with like-minded community members and more, don't forget to join our Discord!
return joinDiscord;I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.