Req.json() is of type any: is this intended?
Answered
Forest bachac posted this in #help-forum
Forest bachacOP
Currently, I'm doing
req.json() in a couple route handlers. Although, what I realize is that its of type any, when it really should be unknown. Is this intended?Answered by Rafael Almeida
I believe this behavior is inherited from the type definitions for
fetch from the browser, it is the same for JSON.parse. ideally it should be unknown but it is not the case. fwiw ts-reset fixes this and a few other inconveniences: https://github.com/total-typescript/ts-reset4 Replies
European sprat
Why should it be unknown?
Forest bachacOP
Bc you dont know what it is
Its safer for exmaple if im feeding the value to another function that has types set, when its set to any eslint/typescript compiler wont say anything
I believe this behavior is inherited from the type definitions for
fetch from the browser, it is the same for JSON.parse. ideally it should be unknown but it is not the case. fwiw ts-reset fixes this and a few other inconveniences: https://github.com/total-typescript/ts-resetAnswer