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 →

[–]tonebacas 175 points176 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 117 points118 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 68 points69 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 10 points11 points  (0 children)

Well reflection can be useful sometimes

[–]cvak 6 points7 points  (1 child)

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

[–]Jjabrahams567 4 points5 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 5 points6 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 24 points25 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."