facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.39k stars 1.82k forks source link

Add Typescript validation to pipelines to prevent regressions #4755

Open drewatk opened 2 months ago

drewatk commented 2 months ago

We'll need a way to validate Typescript code to ensure that we do not regress the generated code as we are moving towards typechecking checking generated TS files in #4745.

Discussion below with @captbaritone:

Yeah, for Flow we have our own codebase as a massive test case. For TypeScript we'll need something to echo that setup. Running typescript on integration tests could be a great way to achieve that pretty cheaply.

We have rust utilities that materialize these fixture files into multiple files in a directory and then run the compiler on them. Maybe that test could also run the TypeScript type check on them? Maybe a little brittle to shell out to TypeScript from within the Rust tests, but probably worth it.

Will require a little fiddling to get it to work both internally and in GitHub CI and ensure we keep the same version(s?) of TypeScript, but I bet we can figure it out.

Here's where we run the integration tests: https://github.com/facebook/relay/blob/main/compiler/crates/relay-compiler/tests/relay_compiler_integration.rs

cc @rbalicki2 regarding upstreaming TypeScript types and how we might add tests which assert their correctness.

_Originally posted by @captbaritone in https://github.com/facebook/relay/pull/4753#discussion_r1698864973_

captbaritone commented 2 months ago

Thanks for pulling this up into a top-level issue!