News for hackers. Stuff that matters.
Re:Why doesn't TypeScript properly type Object.keys? by consilient on Saturday June 24, 2023 @06:34PM (#36463243)
> Usually the lie is in your own code or bad dependencies when an “unknown” type (including “any”) is cast to a concrete type without being validated.

Yes, but one of those bad dependencies is the standard library.

Re:Why doesn't TypeScript properly type Object.keys? by __ryan__ on Saturday June 24, 2023 @08:22PM (#36463999)
When does the standard library lie in this case?
Re:Why doesn't TypeScript properly type Object.keys? by consilient on Saturday June 24, 2023 @10:40PM (#36464706)
Things are `any` when they should be `unknown` or generic, mostly. Off the top of my head:

- `JSON.parse` and `.json()` on response bodies both return `any`.

- `JSON.stringify`'s `replacer` argument is of type `(key: any, string: any) => any`.

- `PromiseRejectedResult["reason"]` is `any`.

There are certainly many others.