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

feat: Add LocalsExt interface #1114

Merged
merged 3 commits into from
Nov 6, 2023
Merged

Conversation

NathanHuisman
Copy link

@NathanHuisman NathanHuisman commented Nov 5, 2023

PR Type

  • Feature

What is the current behavior?

I found myself struggling to extend FetchEvent.locals globally, because typescript does not allow declaration merging of non-method members of interfaces (see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces)

What is the new behavior?

We can improve this by adding a LocalsExt interface that can be merged in your own app.d.ts like this:

import type { LocalsExt } from "solid-start/server";

declare module "solid-start/server" {
  interface LocalsExt {
    auth?: AuthUser;
  }
}

Other information

Issue #848

I saw Lucia doing something similar with a namespace

@NathanHuisman NathanHuisman changed the title Add LocalsExt interface feat: Add LocalsExt interface Nov 5, 2023
@ryansolid
Copy link
Member

Ok thank you.

@ryansolid ryansolid merged commit 4339dde into solidjs:main Nov 6, 2023
9 checks passed
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.

2 participants