Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

import type { DocumentNode } from 'graphql/language/ast'; '=' expected. error #187

Closed
abrehamgezahegn opened this issue Aug 11, 2020 · 6 comments · Fixed by #191
Closed

Comments

@abrehamgezahegn
Copy link

Typescript throws this error.

`node_modules/graphql-request/dist/types.d.ts(1,13):
'=' expected. TS1005

1 | import type { DocumentNode } from 'graphql/language/ast';
| ^
2 | export declare type Variables = {
3 | [key: string]: any;
4 | };

`

I fixed it by editing nodemodules/graphql-request/dist/types.d.ts file by removing type from line 1. And the error is gone. But am not sure that is really a fix.

@zchryst
Copy link
Contributor

zchryst commented Aug 15, 2020

I'm experiencing the same problem

@zchryst
Copy link
Contributor

zchryst commented Aug 16, 2020

I've fixed this in this pull request #191

@jasonkuhrt
Copy link
Member

This syntax comes from TS 3.8 and up. You are probably on an older version.

I don't think the import type is essential though for our use-case here. And it wasn't my intention to force users to upgrade to TS 3.8+.

@GerbenRampaart

This comment has been minimized.

@jasonkuhrt
Copy link
Member

@GerbenRampaart yep it is now required to have graphql installed to use graphql-request in TS. In JS it doesn't matter.

@msilynx
Copy link

msilynx commented May 3, 2021

rror: node_modules/@aws-amplify/api-graphql/lib-esm/types/index.d.ts:1:30 - error TS7016: Could not find a declaration file for module 'graphql/error/GraphQLError'. 'xxx/node_modules/graphql/error/GraphQLError.js' implicitly has an 'any' type. Try npm install @types/graphql if it exists or add a new declaration (.d.ts) file containing declare module 'graphql/error/GraphQLError'; 1 import { GraphQLError } from 'graphql/error/GraphQLError'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Add index.d.ts under src with:

  declare module 'graphql/language/ast' { export type DocumentNode = any }
  declare module 'graphql/error/GraphQLError' { export type GraphQLError = any }

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants