#const data = await res.json() ! Unsafe assignment of `any` value
23 messages · Page 1 of 1 (latest)
First time seeing the rule, is there documentation for it?
Wild guess, try:
const data: unknown = await res.json()
yeah that works to remove the error
I guess that package from that guy on youtube would fix it too... what's it called? Ts-reset?
that removes the baked in anys
Yeah that one works as well.
seems pretty silly to have anything be any by default when unknown exists
Yeah I wish TS would just changed the anys in the few places they still use it.
but I guess unknown didn't exist when they implemented it and they can't break peoples' stuff
oh yeah that feels nice to not do the data: unknown thing
Yep, do keep in mind their warning about not using ts-reset in library code though.
yeah I know about that
this component is actually going to be possible to npm install, but luckily it's been decided to depreciate that part of the system
guess I should do the unknown dance anyway to stay on the safe side
Do you have lots of raw fetch calls?
I find it that fetch is a bit too low level, and usually you would wrap it and expose a higher level API like fetchPeople etc, so you are really having to do data: unknown in those few places.
just this one
well, I mean just this one wrapper like that
so it's not a problem, but it was a nice excuse to try ts-reset, which I've been meaning to do since I head about it
Removing anys from JSON.parse and res.json is probably the best thing yeah, the others are kind of 🤷♂️
I didn't check the full list but yeah when I saw this error earlier after messing around with eslint config I felt a bit rustled