dotansimha/graphql-code-generator

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

Open

#5,348 创建于 2021年1月3日

在 GitHub 查看
 (0 评论) (13 反应) (0 负责人)TypeScript (1,295 fork)batch import
corehelp wantedkind/enhancementplugins

仓库指标

Star
 (10,341 star)
PR 合并指标
 (平均合并 46天 1小时) (30 天内合并 11 个 PR)

描述

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);
}

贡献者指南