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(nextjs): Improve type inference for the return type of auth helper (#2047) #2049

Merged
merged 1 commit into from
Nov 6, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/new-eels-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/backend': patch
'@clerk/nextjs': patch
---

Fix type inferance for auth helper.
2 changes: 1 addition & 1 deletion packages/backend/src/tokens/authObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export function sanitizeAuthObject<T extends Record<any, any>>(authObject: T): T
*/
export const makeAuthObjectSerializable = <T extends Record<string, unknown>>(obj: T): T => {
// remove any non-serializable props from the returned object
// eslint-disable-next-line @typescript-eslint/no-unused-vars

const { debug, getToken, ...rest } = obj as unknown as AuthObject;
return rest as unknown as T;
};
Expand Down
4 changes: 3 additions & 1 deletion packages/nextjs/src/server/getAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const createGetAuth = ({
return (
req: RequestLike,
opts?: GetAuthOpts,
): AuthObjectWithDeprecatedResources<SignedInAuthObject | SignedOutAuthObject> => {
):
| AuthObjectWithDeprecatedResources<SignedInAuthObject>
| AuthObjectWithDeprecatedResources<SignedOutAuthObject> => {
const debug = getHeader(req, constants.Headers.EnableDebug) === 'true';
if (debug) {
logger.enable();
Expand Down
Loading