Skip to content

Export a type for Remix v2 MetaFunctions #9358

Closed
@onurtemizkan

Description

@onurtemizkan

Discussed in #9340

Originally posted by tmcw October 23, 2023
I just updated to Remix v2 and the newest version of @sentry/remix. My MetaFunction looks like

export const meta: MetaFunction = ({ data }) => {
 return [
   {
     "sentry-trace": data.sentryTrace || "dev",
   },
   {
     baggage: data.sentryBaggage || "dev",
   }
 ];
};

Previously, this was fine because MetaFunction made data typed any but now that it's typed unknown, TypeScript won't abide by this. The Sentry machinery that inserts sentryTrace seems to be behind the scenes and there's no type helper that I can find that would make this type-check properly.

Also, I see that there are integration tests for this but it doesn't seem like the documentation mentions using MetaFunction anymore?

I don't want to type data as any because it would make any other data access in my meta function unsafe. Is there a good way to solve this problem?

We should export a type to be used in place of MetaFunction for Remix v2.

Metadata

Metadata

Assignees

Labels

Package: remixIssues related to the Sentry Remix SDK

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions