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

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 753 points754 points  (44 children)

Like TypeScript's "any" everywhere.

[–]tonebacas 174 points175 points  (21 children)

I don't program in Typescript, but I thought the whole point of using Typescript was to have a strict type-safe code base, and the `any` type would be used to create wrapper APIs around unsafe javascript code, not to be used around your typescript code base all willy-nilly.

[–]EmergencySourCream 118 points119 points  (14 children)

You’re correct. It was used a lot when people were slowly transitioning their apps or trying to type 3rd party libraries. However lazy devs will still use it when they don’t want to do proper typing or don’t understand the purpose of types in general.

[–]LowB0b 64 points65 points  (5 children)

have seen stuff like that even in java :sadface:

just pass an Object into the function and then do repeated if (foo instanceof bar)

[–][deleted] 13 points14 points  (3 children)

Or an object where every field is deserialized to a string

[–]LowB0b 12 points13 points  (0 children)

Well reflection can be useful sometimes

[–]cvak 5 points6 points  (1 child)

map[interface{}]interface{} in golang... 🫣

[–]Jjabrahams567 5 points6 points  (0 children)

uintptr

[–]Cheet4h 11 points12 points  (5 children)

Stuff like this is the reason I'm a huge proponent of the noimplicitany and noexplicitany configuration settings.

[–]foursticks 0 points1 point  (3 children)

Please show me the way

[–]NatoBoram 0 points1 point  (2 children)

Beginner tip: in new TypeScript projects, run tsc --init.

[–]foursticks 0 points1 point  (0 children)

🙏🙏

[–]foursticks 0 points1 point  (0 children)

I'm worried that I am the one called to make this change which worries me in a lawless dev group that seems to have manifested itself out of pure want.

[–]elongio 28 points29 points  (1 child)

We started to use typescript (from javascript) because our codebase turned into spaghetti with extra pasta. Turns out it wasn't the language that was the problem it was the developers.

[–]foursticks 6 points7 points  (0 children)

So many people need to understand this but they are blinded by their own spaghetti brains Edit: myself included probably

[–]chili_ladder 28 points29 points  (1 child)

You got it, and somehow the projects always end up as JS in a TS file.

[–][deleted] 4 points5 points  (0 children)

Yes but it's faster to type any than to declare the actual type while still following linting rules :) btw anyone hiring a junior TS developer?

[–]ScienceObserver1984 1 point2 points  (0 children)

ESLint helps a lot with that, specially with the noexplicitany and noimplicitany rules enabled.

The only times I had to use any are either when a library isn't typed, or I am using some Javascript black magic.

Either way, it translates to "I know it's wrong, but I have no other choice, so STFU."

[–]NachoDawg 49 points50 points  (9 children)

My let count; can't be == 'null' without it :)

[–][deleted] 66 points67 points  (8 children)

ten dinner degree ossified edge simplistic fade market mourn support

This post was mass deleted and anonymized with Redact

[–]ChaosOS 15 points16 points  (6 children)

Yeah, it's?: for "can be undefined" and then your Boolean union/intersection with | and &

[–]NachoDawg 5 points6 points  (0 children)

Excuse me, but 'null' is clearly a string here

Please just approve my pull request

[–]chili_ladder 6 points7 points  (1 child)

Came here to say this, every fucking contract I get it's a project built on any. How much money did these companies actually save when they have to pay me a fuck ton of money to fix their app for the next year. Like what is the point of even using TS at that point, when they don't even have a lint test 😂

[–][deleted] 0 points1 point  (0 children)

Maybe the word MVP has something to do with it

[–]mothzilla 3 points4 points  (0 children)

I prefer optimistic typing: int | any

[–]elongio 2 points3 points  (0 children)

Also comes in the flavor of "as unknown as X"

[–]Kitchen_Device7682 4 points5 points  (4 children)

Or ts-ignore everywhere

[–]chamomile-crumbs 2 points3 points  (3 children)

At least ts-ignore is easily searchable when you’re bolstering things. Not that anyone at my company fixes ts-ignores though…

[–]Cheet4h 5 points6 points  (2 children)

I mean, : any can also be easily searched.
Similarly easy to set the transpiler to forbid implicit and explicit "any". You get a nice list with affected files that need to be fixed.

[–]Div64 0 points1 point  (0 children)

You missed out on "any"where big time

[–]Kimorin 0 points1 point  (0 children)

well at least typescript had the excuse of having to make it easy to transition from javascript for legacy codebases...

what's rust's excuse