remix icon indicating copy to clipboard operation
remix copied to clipboard

feat(remix-server-runtime): add loader context generic types

Open rwu823 opened this issue 3 years ago • 8 comments

Because the context does not change too often, users can easily customize it without having to use the type to correspond to it every time.

for example:

import { LoaderFunction } from 'remix';

type MyContext  = {
  user: string
}

type LoaderFunctionWithContext = LoaderFunction<MyContext>

export const loader: LoaderFunctionWithContext = () => {}

rwu823 avatar Feb 25 '22 08:02 rwu823

Hi @rwu823,

Welcome, and thank you for contributing to Remix!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected].

Thanks!

- The Remix team

remix-cla-bot[bot] avatar Feb 25 '22 08:02 remix-cla-bot[bot]

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

remix-cla-bot[bot] avatar Feb 25 '22 08:02 remix-cla-bot[bot]

Hi @rwu823 and sorry for the delays. Can you rebase your PR to target the dev branch?

machour avatar Mar 20 '22 07:03 machour

@machour done.

rwu823 avatar Mar 21 '22 13:03 rwu823

@rwu823 Could you please rebase your branch on latest dev & resolve conflicts?

MichaelDeBoey avatar Mar 28 '22 09:03 MichaelDeBoey

@MichaelDeBoey done.

rwu823 avatar Mar 30 '22 14:03 rwu823

Just came across this today and this PR would be nice to have.

My use case is that I would like to use the context for dependency injection w.r.t Actions and Loaders, so it would be nice to type the context and get autocomplete without having to typecast context in each loader.

TillaTheHun0 avatar Apr 08 '22 20:04 TillaTheHun0

Just checking in, any way we can get this merged in? This becomes especially helpful now that the meta function is typed off of the loader. Without this change, meta will always consider data to be any if the loader function is typed.

mattrigg9 avatar Sep 21 '22 16:09 mattrigg9

This PR has been automatically closed because we haven't received a response from the original author 🙈. This automation helps keep the issue tracker clean from PRs that are unactionable. Please reach out if you have more information for us! 🙂

github-actions[bot] avatar Feb 03 '23 00:02 github-actions[bot]