Skip to content

Typings for Send accept a Promise but the function doesn't await it #6385

Open
@Sainan

Description

@Sainan

Environment information

Version: 5.0.1 (latest)
Platform: Windows 10 (x86_64)
Node.js version: 22.14.0
TypeScript version: 5.5.4

What steps will reproduce the bug?

const getData = async (): Promise<Record<string, string>> => {
    return { hello: "world" };
};

router.get("/test", (_req, res) => {
    res.json(getData());
});

This compiles successfully but the response will be {}.

I expected either a compiler error or for the response to be {"hello":"world"}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    typescriptTopics related to TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions