Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Emitted types are invalid? #205

Open
SpaghettiC0des opened this issue Oct 16, 2020 · 6 comments
Open

Emitted types are invalid? #205

SpaghettiC0des opened this issue Oct 16, 2020 · 6 comments

Comments

@SpaghettiC0des
Copy link

Sorry for my ignorance, I just started using Relay and friends. I chose it over other existing GraphQL client because IMHO, it is worth it in the long run.

I am following the todo list tutorial on Relay's docs and converting the HTML into React Native. There's no error on the runtime but there are static type errors, especially on the generated types for fragments.

Here's a reproduction of the issue, you don't need to run it just open it on VScode.

Open the following files:

  1. TodoList.tsx@line:16
  2. TodoScreen.tsx@line:30
@sibelius
Copy link
Contributor

what are the errors? can you provide them here?

@SpaghettiC0des
Copy link
Author

@sibelius

Type '{ readonly " $fragmentRefs": FragmentRefs<"TodoList_user">; } | null' is not assignable to type '_FragmentRefs<"TodoList_user">'.
  Type 'null' is not assignable to type '_FragmentRefs<"TodoList_user">'.ts(2322)
TodoList.tsx(8, 3): The expected type comes from property 'user' which is declared here on type 'IntrinsicAttributes & MappedFragmentProps<Pick<Props, "user">> & { componentRef?: ((ref: any) => void) | undefined; } & { ...; }'

@SpaghettiC0des
Copy link
Author

@sibelius Similar issue when I use the experimental hooks. On the same repro branch above, please check out hooks branch, then open TodoScreen line 25.

<TodoApp /> contains a nested fragment, but it seems like it does not emit the proper type on the root component/query?

Type '{ readonly " $fragmentRefs": FragmentRefs<"TodoApp_viewer">; } | null' is not assignable to type '_FragmentRefs<"TodoApp_viewer">'.
  Type 'null' is not assignable to type '_FragmentRefs<"TodoApp_viewer">'.ts(2322)
TodoApp.tsx(13, 3): The expected type comes from property 'viewer' which is declared here on type 'IntrinsicAttributes & MappedFragmentProps<Pick<Props, "viewer">> & { componentRef?: ((ref: any) => void) | undefined; } & { ...; }'

@filame
Copy link

filame commented May 17, 2021

@karlmarxlopez have you found a solution to this issue? I'm currently using typescripts as keywords which doesn't feel good.

@SpaghettiC0des
Copy link
Author

@filame I think I ended up typecasting it. Something like this, someFragmentData as MyFragment_foo$key

@filame
Copy link

filame commented May 25, 2021

@filame I think I ended up typecasting it. Something like this, someFragmentData as MyFragment_foo$key

Ok, same for me. Thanks for your reply!

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

No branches or pull requests

3 participants