Skip to content

rawBody can be undefined but it's typed as a string #174

Description

@btabram

Hello, just wondering if this is intentional or not? It feels misleading and like it could lead to runtime bugs

rawBody is declared as a string:

declare module 'koa' {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface Request {
body?: unknown;
rawBody: string;
}
}

but in practice it will be undefined if a suitable body type is not found:

if (!bodyType) return {} as Record<string, string>;

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions