Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] relax endpoint headers type definition #3201

Merged
merged 3 commits into from Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/grumpy-days-compete.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Allow multiple different headers returned from one endpoint
2 changes: 1 addition & 1 deletion packages/kit/src/utils/http.js
@@ -1,5 +1,5 @@
/**
* @param {Record<string, string | string[]>} headers
* @param {Record<string, string | string[] | undefined>} headers
* @param {string} key
* @returns {string | undefined}
* @throws {Error}
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/types/endpoint.d.ts
Expand Up @@ -5,7 +5,7 @@ type DefaultBody = JSONString | Uint8Array;

export interface EndpointOutput<Body extends DefaultBody = DefaultBody> {
status?: number;
headers?: ResponseHeaders;
headers?: Partial<ResponseHeaders>;
body?: Body;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/kit/types/hooks.d.ts
Expand Up @@ -15,7 +15,7 @@ export interface ServerRequest<Locals = Record<string, any>, Body = unknown> {

export interface ServerResponse {
status: number;
headers: ResponseHeaders;
headers: Partial<ResponseHeaders>;
body?: StrictBody;
}

Expand Down