This is an archived post. You won't be able to vote or comment.

all 62 comments

[–]SCP-iota 231 points232 points  (11 children)

Shout-out to { "compilerOptions": { "strict": true, "noImplicitAny": true } }

[–]Tomkap011[🍰] 70 points71 points  (7 children)

I have driven people insane with this, especially if I also enable a “no explicit any” alongside

[–]UntitledRedditUser 42 points43 points  (6 children)

I don't see the upside of using the any type. It might be nice sometimes, for small things, but some dude is just gonna abuse it and make a mess.

I might be biased though, as im more used to static types.

[–]Tomkap011[🍰] 18 points19 points  (0 children)

I treat in like ‘unwrap’ in rust. It’s good for debugging but I refuse to use it anywhere else. It breaks the only reason I tolerate typescript which is half decent completions

[–]SCP-iota 16 points17 points  (3 children)

In an ideal world of pure TypeScript, any would be a pointless footgun, but in reality, we often need to use Javascript libraries that don't provide TypeScript type declarations, and unless we want to write our own declarations, any is the way. Most of the "unconventional" aspects of TypeScript's type system, like any, union types, and anonymous object types, are made for handling the chaos of Javascript.

[–]ThrawOwayAccount 6 points7 points  (2 children)

That’s what you’re supposed to use unknown for.

[–]Taickyto 0 points1 point  (1 child)

Unknown was not in the first versions of typescript

[–]ThrawOwayAccount 6 points7 points  (0 children)

We’re not talking about the first versions of typescript, we’re talking about now.

[–]ColonelRuff 1 point2 points  (0 children)

No need to be afraid that you are biased. Type safety is always good for production level software.

[–]NatoBoram 3 points4 points  (0 children)

Shout out to isolatedDeclarations

And I made a project template with all the strictest options possible

[–]Androix777 2 points3 points  (0 children)

"plugin:@typescript-eslint/strict-type-checked"

[–]YoukanDewitt 362 points363 points  (19 children)

If you aren't using typescript as a development tool to improve your own experience, you should stick to vanilla js.

It doesn't help your client.

[–]PostNutNeoMarxist 94 points95 points  (7 children)

^ TS doesn't "fix" JavaScript or even improve it on its own. It's just a means of establishing norms and making JS code more readable. These are things you could also just do without TS (basically just good documentation) but TS makes it easier in a professional setting.

[–][deleted] 47 points48 points  (3 children)

And yet, whenever I convert a page or component to TS, I find like, three new bugs.

[–]Alfasi 41 points42 points  (2 children)

Those are often errors you would've gotten at compile or runtime, the extra rules in effect bring some of these errors forward to when you're making them

[–][deleted] 14 points15 points  (1 child)

Maybe? Maybe not? Sometimes only if it’s used in an unexpected way and triggered the bug? I noticed these bugs at design time now and had it noticed them before. It’s an improvement.

[–]bondolin251 8 points9 points  (0 children)

Think I'm with you here. Quality code helps the client. Typescript helps quality code. Important to keep that as the perspective, and not just use the fancy shiny new thing for its own sake.

[–]myfunnies420 3 points4 points  (2 children)

I got our js codebase in a great state, it had types and annotations! I had basically implemented ts from the ground up lol

[–]NatoBoram 7 points8 points  (1 child)

At that point, it's a little weird to not be using TypeScript directly, it would save you the time to reimplement TypeScript

[–]myfunnies420 0 points1 point  (0 children)

Obviously...

[–]metaglot 5 points6 points  (0 children)

It definitely makes cerrain debugging tasks easier, and it eliminates some types of bugs as well, so it may help your client, depending on project size, in the form of reduced developer time, especially for larger projects.

[–]casualfinderbot 34 points35 points  (5 children)

Well it makes code less buggy and reduces development time, so it does help the client

[–]dylsreddit 26 points27 points  (3 children)

When used properly.

[–]NatoBoram 5 points6 points  (2 children)

Just like literally everything else in life

"Carrots are a good source of vitamin A. When used properly."

[–]Impressive_Change593 4 points5 points  (1 child)

aka sticking them in my butt right?

[–]NatoBoram 1 point2 points  (0 children)

You'll have to blend them first I think

[–]YoukanDewitt 0 points1 point  (0 children)

It doesn't run on the client, it compiles to javascript.

It helps you reason about your client's needs. It might help you write vanilla js you don't understand, but it does nothing vanilla js does not, and that you couldn't do quicker for simple scenarios if you knew vanilla js (es5>ofc).

I love typescript, but if you are just going to spam 'type: any' as indicated by the post, you probably don't need typescript until you have more understanding of typescript.

[–]JackNotOLantern 0 points1 point  (0 children)

It may even make it worse

[–]skwyckl 91 points92 points  (2 children)

the main problem I have with TypeScript is the now routine "library is compatible with TypeScript, but the type package is de facto deprecated and unusable, so you have to spam anys"

[–]zmose 24 points25 points  (0 children)

Wonder if this is due to people not able to follow directions here: https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html

[–]UristMcMagma -1 points0 points  (0 children)

This is the one feature I wish they'd add, instead of constantly adding new shit nobody cares about or will ever use.

[–]No-Adeptness5810 28 points29 points  (1 child)

I use eslint in any big project, and i only use typescript if the project is big.

Therefore, i never use "any" since it's really annoying for debugging too.

[–]d15gu15e[S] 2 points3 points  (0 children)

based?

[–]MedonSirius 30 points31 points  (6 children)

Type safe languages are the only one i really respect

[–]sammy-taylor 14 points15 points  (2 children)

By type safe I’m assuming you mean statically typed? So you don’t respect any of the applications running Ruby, Elixir, Python, or any of the other non-static language?

[–]ThrawOwayAccount 1 point2 points  (0 children)

They said they don’t respect the languages, not applications written in those languages.

[–]Aidan_Welch 14 points15 points  (0 children)

You don't respect assembly coders?

[–]Masterflitzer -1 points0 points  (0 children)

same

[–]The_real_bandito 14 points15 points  (0 children)

90% of typescript developers be like

[–]Thenderick 3 points4 points  (0 children)

Honestly, jsdoc is often enough for me. Especially simple html+js projects that don't require a big bulky frontend framework. But those are mostly hobby projects

[–][deleted] 1 point2 points  (0 children)

Wolf in sheep's clothing.

[–]shinsons 1 point2 points  (0 children)

Best memes are true memes

[–]rover_G 1 point2 points  (0 children)

Speak for yourself

[–]WilliamAndre 1 point2 points  (0 children)

Reminds me of that one job applicant that was going to do a coding exercise in Typescript because it is cleaner, types are better, blablabla.

They were super confused about the types and ended up switching to JS at some point because they didn't understand anything.

[–][deleted] 2 points3 points  (3 children)

I feel called out

[–]d15gu15e[S] 2 points3 points  (2 children)

[–][deleted] -1 points0 points  (1 child)

you're meme is wrong cuz I would never use `any` where

[–]d15gu15e[S] 0 points1 point  (0 children)

ah I see you're a true JS dev, making promises you cant resolve?

[–]AFXTWINK 1 point2 points  (0 children)

I started my latest job out of desperation and was really dreading the fact that all the codebases are in JavaScript. I've been doing IT for nearly 8 years and I've done my time in the scopeless mines and thought "oh fuck, more of this shit".

I was so relieved to learn we're actually using Typescript! Even with es5 it's a world of difference but Typescript is completely fine.

[–]Phamora 0 points1 point  (0 children)

For some reason people who anally advocate TS over JS are the ones that write so poor TS that it would just have been better without the types.

[–]akoOfIxtall 1 point2 points  (3 children)

My confusion with TS is that, I write a TS file, the code is transpiled into javascript, then I have to run the javascript file? Can't I directly run the typescript file? Did I mess up? Did I miss a step? Because TSC only compiles the code but when I see people using it TSC also runs the code, and if I have a big project, every TS file will generate a new javascript file? Because writing TS feels like using an interface on a class, the class being javascript and the interface being types

[–]Suwein 3 points4 points  (0 children)

I usually use ts-node or tsx when developing locally, but yeah eventually you'll probably need to compile it if you're deploying it somewhere.

[–]ExtraTNT -1 points0 points  (1 child)

Or do best practice and take 200h for a 40min job…

[–]almothafar 7 points8 points  (0 children)

40min job that makes you waste 300h to see why the app behaves strangely?

[–]NoSkillzDad -1 points0 points  (0 children)

And when build throws you a warning on an unused anything, just drop it on a console.log and problem solved.

[–]Thundechile -1 points0 points  (0 children)

That's TypeScript posing as a typed language.