by nailer · 6y ago · 0 comments
I understand 'incorrect values' (this is true, see https://github.com/Microsoft/TypeScript/issues/15480) .
But TypeScript definitely doesn't like adding additional fields. Right now I'm working on TypeScript, added the new Fastify raw body plugin, and forgot to extend our custom Request type. The error is:
Property 'rawBody' does not exist on type 'CustomRequest<DefaultQuery, DefaultParams, DefaultHeaders, any>'.ts(2339)
Ie, we can't just add a field.Appreciate I may be wrong, or we have different definitions here, but I'd like to discuss.
interface MyType {
a: number;
}
function process(value: MyType) {
console.log(value);
}
const value = { a: 1, b: 2 };
process(value);