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

Remove @ts-nocheck from generated Typescript files #4745

Open
drewatk opened this issue Jul 16, 2024 · 0 comments
Open

Remove @ts-nocheck from generated Typescript files #4745

drewatk opened this issue Jul 16, 2024 · 0 comments

Comments

@drewatk
Copy link
Contributor

drewatk commented Jul 16, 2024

In order to ensure type safety, generated typescript files should not be exported with @ts-nocheck. This is currently present in both generated types for resolvers as well as generated fragments which are referenced from components. In order to create type assertions within this file, we will need to begin type-checking these files.

Related: #4742
This is part of the requirement for the resolver context work mentioned in #4000 and #4704

facebook-github-bot pushed a commit that referenced this issue Aug 7, 2024
Summary:
A fix for a typescript generation bug discovered from the work in #4753, with efforts to enable checking for all TS generated files #4745

This fixes a class of Typescript errors in generated typescript files with TS checking enabled:
```
/src/__generated__/mutation.graphql.ts(11,27): error TS2305: Module '"relay-runtime"' has no exported member 'Mutation'.
/src/__generated__/mutation.graphql.ts(11,27): error TS6133: 'Mutation' is declared but its value is never read.
```

The root cause is the exported type is both not exported by the TS types, and not used due to typescript using the `export default` syntax.
Where flow would generate the following export:
```
module.exports = ((node/*: any*/)/*: Mutation<
  validateMutationTest9ChangeNameIncludeMutation$variables,
  validateMutationTest9ChangeNameIncludeMutation$data,
>*/);
```
Typescript would generate the following, not using the `Mutation` type:
```
export default node;
```

This fix removes the extraneous import type when the language is set as typescript.

Pull Request resolved: #4754

Differential Revision: D60604034

fbshipit-source-id: f38fc80bba3b549a22ebbca544dca1f9e940cce0
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

1 participant