dotansimha/graphql-code-generator

Add return type to function to avoid eslint warning explicit-module-boundary-types

Open

#5348 aperta il 3 gen 2021

Vedi su GitHub
 (0 commenti) (13 reazioni) (0 assegnatari)TypeScript (1295 fork)batch import
corehelp wantedkind/enhancementplugins

Metriche repository

Star
 (10.341 star)
Metriche merge PR
 (Merge medio 46g 1h) (11 PR mergiate in 30 g)

Descrizione

I'm using strict typescript and I want all functions to explicitly define their return types. However, when generating the types using code generator, the function have no return type.

Of course I can disabled eslint for the file (/* eslint-disable @typescript-eslint/explicit-module-boundary-types */), but this is messy

Example ;

export function useFindRefBudgetEntityQuery(
	baseOptions?: Apollo.QueryHookOptions<
		FindRefBudgetEntityQuery,
		FindRefBudgetEntityQueryVariables
	>
) {
	return Apollo.useQuery<
		FindRefBudgetEntityQuery,
		FindRefBudgetEntityQueryVariables
	>(FindRefBudgetEntityDocument, baseOptions);
}

the returnType is compiled but not set to this function

export type FindRefBudgetEntityQueryResult = Apollo.QueryResult<
	FindRefBudgetEntityQuery,
	FindRefBudgetEntityQueryVariables
>;

adding it works fine

export function useFindRefBudgetEntityQuery(
	baseOptions?: Apollo.QueryHookOptions<
		FindRefBudgetEntityQuery,
		FindRefBudgetEntityQueryVariables
	>
):Apollo.QueryResult<
FindRefBudgetEntityQuery,
FindRefBudgetEntityQueryVariables
> {
	return Apollo.useQuery<
		FindRefBudgetEntityQuery,
		FindRefBudgetEntityQueryVariables
	>(FindRefBudgetEntityDocument, baseOptions);
}

Guida contributor