#TypeScript / Remix AppContext (n00b) Question

1 messages · Page 1 of 1 (latest)

dusty sail
#

Hello! I am creating a request handler in a JavaScript file using an express backend like so:

/* ... */
const user = await Session.GetUserFromRequest(req); // req defined elsewhere
return createRequestHandler({
  build,
  mode: process.env.NODE_ENV,
  getLoadContext(req, res) {
    return {user};
  },
})(req, res, next);
/* ... */

However, when I go to actually access it in an action or loader later on, like so:

export async function action({request, context}: ActionArgs) {
  const {user} = context;
  console.log(user.id)
}

...TypeScript complains that user is of type unknown. How can I arbitrarily define properties on this app context (that is defined in JavaScript) with types accessible in TypeScript?

Thanks!

storm pecan