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

Using as const on an enum triggers typescript errors on unstable_defineLoader #9614

Open
IgnisDa opened this issue Jun 14, 2024 · 0 comments

Comments

@IgnisDa
Copy link

IgnisDa commented Jun 14, 2024

Reproduction

https://stackblitz.com/edit/remix-run-remix-yjtvxa?file=app%2Froutes%2F_index.tsx

System Info

System:
    OS: Linux 6.9 Arch Linux
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
    Memory: 12.35 GB / 27.26 GB
    Container: Yes
    Shell: 5.2.26 - /bin/bash
  Binaries:
    Node: 22.1.0 - ~/.proto/bin/node
    Yarn: 4.1.1 - ~/.proto/shims/yarn
    npm: 10.7.0 - ~/.proto/shims/npm
    bun: 1.1.8 - ~/.proto/bin/bun
  npmPackages:
    typescript: 5.5.0-beta => 5.5.0-beta

Used Package Manager

yarn

Expected Behavior

There should be no typescript errors. All types being sent are serializable.

Actual Behavior

There is a typescript error:

Argument of type '({ params }: LoaderArgs) => Promise<{ metadataMapping: { readonly AUDIO_BOOK: readonly [MediaSource]; }; }>' is not assignable to parameter of type 'Loader'.
  Type 'Promise<{ metadataMapping: { readonly AUDIO_BOOK: readonly [MediaSource]; }; }>' is not assignable to type 'MaybePromise<DataFunctionReturnValue>'.
    Type 'Promise<{ metadataMapping: { readonly AUDIO_BOOK: readonly [MediaSource]; }; }>' is not assignable to type 'Promise<Serializable>'.
      Type '{ metadataMapping: { readonly AUDIO_BOOK: readonly [MediaSource]; }; }' is not assignable to type 'Serializable'.
        Type '{ metadataMapping: { readonly AUDIO_BOOK: readonly [MediaSource]; }; }' is not assignable to type '{ [key: string]: Serializable; [key: number]: Serializable; [key: symbol]: Serializable; }'.
          Property 'metadataMapping' is incompatible with index signature.
            Type '{ readonly AUDIO_BOOK: readonly [MediaSource]; }' is not assignable to type 'Serializable'.
              Type '{ readonly AUDIO_BOOK: readonly [MediaSource]; }' is not assignable to type '{ [key: string]: Serializable; [key: number]: Serializable; [key: symbol]: Serializable; }'.
                Property 'AUDIO_BOOK' is incompatible with index signature.
                  Type 'readonly [MediaSource]' is not assignable to type 'Serializable'.
                    Type 'readonly [MediaSource]' is not assignable to type '{ [key: string]: Serializable; [key: number]: Serializable; [key: symbol]: Serializable; }'.
                      Index signature for type 'string' is missing in type 'readonly [MediaSource]'.(2345)
@IgnisDa IgnisDa changed the title Using as const as an enum breaks defineLoader Using as const on an enum triggers typescript errors on unstable_defineLoader Jun 14, 2024
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

2 participants