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

MetaArgs should be renamed to MetaFunctionArgs to match the rest of remix API types #9141

Open
lifeiscontent opened this issue Mar 26, 2024 · 5 comments

Comments

@lifeiscontent
Copy link
Contributor

lifeiscontent commented Mar 26, 2024

Reproduction

the API Surface in Remix should be guessable.

System Info

N/A

Used Package Manager

pnpm

Expected Behavior

ActionFunction <-> ActionArgs
Loaderfunction <-> LoaderArgs
MetaFunction <-> MetaArgs

or

ActionFunction <-> ActionFunctionArgs
Loaderfunction <-> LoaderFunctionArgs
MetaFunction <-> MetaFunctionArgs

Actual Behavior

MetaArgs is inconsistent with the rest of the remix API

@kiliman
Copy link
Collaborator

kiliman commented Mar 26, 2024

I'm not sure if it was intentional or accidental.

MetaArgs is different from LoaderFunctionArgs in that:

  1. It's an interface and not a type
  2. It's also a generic type (used to type data and matches)
export function meta({
  data,
  params,
  location,
  matches,
}: MetaArgs<
  typeof loader, // current route loader data type
  {
    "root": typeof rootLoader;      // specify types for parent loader matches
    "routes/parent": typeof parentLoader;
  }
>) {
  console.log(data, params, location, matches);
  const m = matches.find((m) => m.id === "routes/parent");
  console.log(m?.data.name);
  return [
    { title: "New Remix App" },
    { name: "description", content: "Welcome to Remix!" },
  ];
}

@lifeiscontent
Copy link
Contributor Author

lifeiscontent commented Mar 26, 2024

@kiliman yep, I'm aware, just a suggestion so devs can look at the docs less 😅

@lifeiscontent
Copy link
Contributor Author

lifeiscontent commented Mar 26, 2024

@kiliman just out of curiosity do you happen to know why its an interface? are there reasons to do declaration merging on the interface?

@kiliman
Copy link
Collaborator

kiliman commented Mar 26, 2024

No, I'm not sure of the reasoning behind it.

Anyway, it looks like the naming was an oversight. In the Remix v2.0 release, they renamed LoaderArgs => LoaderFunctionArgs. They might have forgotten to do the same for MetaArgs.

https://github.com/remix-run/remix/blob/main/CHANGELOG.md#:~:text=Renamed%20LoaderArgs/ActionArgs%20to%20LoaderFunctionArgs/ActionFunctionArgs

In fairness, the meta function also underwent a breaking change in v2, since now it returns an array instead of an object with keys.

https://remix.run/docs/en/main/start/v2#route-meta

@kiliman
Copy link
Collaborator

kiliman commented Mar 26, 2024

I think they could just add the MetaFunctionArgs as an alias, deprecate MetaArgs, and drop it in v3.

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

No branches or pull requests

3 participants