Skip to content

Response return type for request handlers is incorrect #3676

@Rich-Harris

Description

@Rich-Harris

Describe the bug

We allow Response objects to be returned from request handlers, but that's really just because Response objects happen to include compatible status, headers and body properties. But TypeScript offers to help you construct a Response of your own, which isn't particularly helpful:

image

Reproduction

Create a request handler, add the import('@sveltejs/kit').RequestHandler type, and return something.

Logs

No response

System Info

System:
    OS: macOS 12.0.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 8.65 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Chrome: 97.0.4692.99
    Firefox: 96.0.3
    Safari: 15.1
  npmPackages:
    @sveltejs/vite-plugin-svelte: ^1.0.0-next.32 => 1.0.0-next.32 
    svelte: ^3.44.2 => 3.44.2 
    vite: ^2.7.2 => 2.7.2

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions