Skip to content

rename EndpointOutput to RequestHandlerOutput and tidy up#4109

Merged
Rich-Harris merged 3 commits intomasterfrom
tidy-up-types
Feb 24, 2022
Merged

rename EndpointOutput to RequestHandlerOutput and tidy up#4109
Rich-Harris merged 3 commits intomasterfrom
tidy-up-types

Conversation

@Rich-Harris
Copy link
Copy Markdown
Member

This clarifies the terminology a bit — an endpoint is a module corresponding to a route, a request handler is a function exported from an endpoint. Therefore RequestHandlerOutput makes more sense than EndpointOutput.

It also neatens the type up. Before:

image

After:

image

Before:

image

After:

image

No changeset, since now that these types are private there's no breakage involved.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 24, 2022

⚠️ No Changeset found

Latest commit: cca79c8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Conduitry
Copy link
Copy Markdown
Member

Shouldn't this have a changeset (probably marked as a breaking change) so that the published types are updated, instead of just the site?

@Rich-Harris
Copy link
Copy Markdown
Member Author

It's not a breaking change, since EndpointOutput isn't a public type (as of #4104). As far as a consumer of RequestHandler is concerned, nothing has changed

@Rich-Harris
Copy link
Copy Markdown
Member Author

Just realised there's an errant > in the tooltip, not sure why

image

@bjon
Copy link
Copy Markdown
Contributor

bjon commented Feb 24, 2022

@Rich-Harris Its breaking for us. We're using EndpointOutput.

e.g.

export function internalError(
  msg = `Internal server error`,
): EndpointOutput<string> {
  return {
    status: 500,
    headers: {
      "Content-Type": contentType.textPlain,
    },
    body: msg,
  };
}

@Conduitry
Copy link
Copy Markdown
Member

It sounds like #4104 would have been the breaking change for you then, not this change.

@bjon
Copy link
Copy Markdown
Contributor

bjon commented Feb 24, 2022

@Conduitry Yes you're right. Was on .278

@Rich-Harris
Copy link
Copy Markdown
Member Author

At any rate that's a convincing reason to move RequestHandlerOutput from private.d.ts to index.d.ts, at which point this PR will be an unbreaking change for you (sort of)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants