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

Add Typescript validation to pipelines to prevent regressions #4755

Open
drewatk opened this issue Jul 31, 2024 · 1 comment
Open

Add Typescript validation to pipelines to prevent regressions #4755

drewatk opened this issue Jul 31, 2024 · 1 comment

Comments

@drewatk
Copy link
Contributor

drewatk commented Jul 31, 2024

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 #4753 (comment)

@captbaritone
Copy link
Contributor

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

facebook-github-bot pushed a commit that referenced this issue Sep 20, 2024
Summary:
Fixes #4772

Adds a satisfies assertion to the live resolver import:

```
import {User as userRelayModelInstanceResolverType} from "UserTypeResolvers";
// Type assertion validating that `userRelayModelInstanceResolverType` resolver is correctly implemented.
// A type error here indicates that the type signature of the resolver module is incorrect.
(userRelayModelInstanceResolverType satisfies (
  id: User__id$data['id'],
  args: void,
) => LiveState<mixed>);
```

It will also require a minimum Typescript version of TS 4.9 or higher for consumers, which can be checked as we implement #4755. We may have to have add a feature flag to disable this for consumers of the library which do not meet this minimum standard.

Pull Request resolved: #4797

Reviewed By: tyao1

Differential Revision: D63032995

Pulled By: captbaritone

fbshipit-source-id: be909c70f38312cd5931d7824b2e887b7834dc1c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants