Missing type definition in assignable fragment generated file in Typescript
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
The relay compiler generates invalid type for assignable fragments in Typescript.
This is the generated code for the following fragment:
```ts
graphql`
fragment SetSelectedMerchantProfile_assignable_profile on Profile
@assignable {
__typename
}
`;
```
```ts
/**
* @generated SignedSource<>
* @lightSyntaxTransform
* @nogrep
*/
/* tslint:disable */
/* eslint-disable */
// @ts-nocheck
import type { FragmentRefs } from "relay-runtime";
const node: any = {};
if (__DEV__) {
(node as any).hash = "e25d274594f324a85a2b2e887789c902";
}
export default node;
module.exports.validate = function validate(value: {
readonly __id: string;
readonly __isSetSelectedMerchantProfile_assignable_profile?: string;
readonly " $fragmentSpreads": SetSelectedMerchantProfile_assignable_profile$fragmentType;
}): false | {
readonly __id: string;
readonly __isSetSelectedMerchantProfile_assignable_profile: string;
readonly " $fragmentSpreads": SetSelectedMerchantProfile_assignable_profile$fragmentType;
} {
return value.__isSetSelectedMerchantProfile_assignable_profile != null ? value : false;
};
```
You can see that `SetSelectedMerchantProfile_assignable_profile$fragmentType` is never defined.
If I add
```ts
export type SetSelectedMerchantProfile_assignable_profile$fragmentType = {
readonly __id: string;
readonly __isSetSelectedMerchantProfile_assignable_profile: string;
readonly " $fragmentSpreads": FragmentRefs<"SetSelectedMerchantProfile_assignable_profile">;
};
```
to the generated file then it type checks fine and I can also import the type `SetSelectedMerchantProfile_assignable_profile$fragmentType` for use in my app code.
Contributor guide
Assessment
This issue has not been assessed yet.