Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
volttide66456dI used plenty of any when I first learned it
100110111199756dOnly for Record<string, any> when the occasion calls for it. Which is rare.
But just don’t. Don’t use any, if you can avoid it, and definitely not because you’re too lazy to create proper models.
neeno288256dUsing any often basically defeats the purpose of using typescript in the first place. I only use any if I absolutely have to.
junon298756dNever. I hate typescript so I avoid it but the few times I use it I turn off implicit any because what's the point otherwise.
I use it in test data when I'm too lazy to specify Record<string, any>, for example when returning JSON data in a mock call. If I don't cast the object to any it'll clog up the type system and start complaining about missing properties
Other than that, never
DoddyDigital456dIf I don't know the type before hand, I use 'unknown' or generic type parameters.
'any' opens the floodgates to all sorts of avoidable bugs.
Only when bridging js apps that legitimately have no means of resolving the type until runtime.
Or when I have an algorithm that can take a typed argument, but doesn't care what the type of that argument is after the fact. Builders will run into this one occasion. Same as reducing to Object in C#.
This will remain the case until Typescript gains support for higher kinded types.
i'm currently working on changes to a 10 years old TypeScript app.
i use var.
meaning that I avoid using the typescript unless some "build" error forces me to.
because i don't need extra complications on top of how shitty the app itself is.
Earu6055dI’m currently building a blueprint editor for a project of mine with TypeScript and so far the only instances where I’ve needed “any” were due to the highly generic structures that I have. For instance NodeOutput<T> where it can output literally anything so it makes sense to use “any” in that case. But out of all the TS projects I’ve been working on I can safely say that it’s very rare to NEED “any”.