relay icon indicating copy to clipboard operation
relay copied to clipboard

Add resolver function type assertions for TypeScript

Open captbaritone opened this issue 1 year ago • 0 comments
trafficstars

In order for Resolvers to be fully features in TypeScript we need to ensure the compiler produces type assertions for them in the same way that type assertions are generated for Flow.

Right now there are a few places where the compiler has TODO comments and does not emit helpful types for TypeScript:

  • https://github.com/facebook/relay/blob/59b768080dedee83b336f6047566da3649a0bde6/compiler/crates/relay-typegen/src/typescript.rs#L82
    • The analogous Flow code (which we can ~duplicate) can be found here.
  • https://github.com/facebook/relay/blob/59b768080dedee83b336f6047566da3649a0bde6/compiler/crates/relay-typegen/src/visit.rs#L379
    • I'm not sure why TypeScript is opting out here. I would expect that we could just remove that TS condition.

For testing you can find resolver tests cases in the Flow tests here and copy them into the TypeScript tests directory.

Note that after adding new fixture files you'll need to regenerate the Rust tests that pull in those fixture tests. More info here.

Related: We'll also need to remove the @ts-nocheck from generated TypeScript files. We'll track that in a separate issue.

captbaritone avatar Jul 15 '24 17:07 captbaritone