dotansimha/graphql-code-generator-community
在 GitHub 查看typescript-react-apollo: Invalid TypeScript output when both withHOC and useTypeImports are true
Open
#100 创建于 2020年12月17日
help wanted
仓库指标
- Star
- (136 star)
- PR 合并指标
- (PR 指标待抓取)
描述
Describe the bug
When using typescript-react-apollo plugin, and enabling both withHOC and useTypeImports output is not a valid TypeScript file:
import * as ApolloReactHoc from '@apollo/client/react/hoc';
import type * as ApolloReactHoc from '@apollo/client/react/hoc';
To Reproduce Steps to reproduce the behavior:
- Open live-demo
- Choose the
Operations typestemplate - Change the config to one below
- My GraphQL schema:
# Default from demo
- My GraphQL operations:
# Default from demo
- My
codegen.ymlconfig file:
generates:
types-and-hooks.tsx:
config:
withHOC: true
useTypeImports: true
plugins:
- typescript
- typescript-react-apollo
Expected behavior
Only this line should be in the output:
import * as ApolloReactHoc from '@apollo/client/react/hoc';
Actual behavoir Both lines are in the output:
import * as ApolloReactHoc from '@apollo/client/react/hoc';
import type * as ApolloReactHoc from '@apollo/client/react/hoc';
Environment: Using the live-demo reproduces it
- OS:
@graphql-codegen/...:- NodeJS:
Additional context