Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Cannot use namespace 'DocumentNode' as a type. #2362

Closed
hoang-innomize opened this issue Dec 17, 2018 · 21 comments
Closed

Cannot use namespace 'DocumentNode' as a type. #2362

hoang-innomize opened this issue Dec 17, 2018 · 21 comments
Assignees
Labels
API Related to REST API issues investigating This issue is being investigated

Comments

@hoang-innomize
Copy link

hoang-innomize commented Dec 17, 2018

I am getting below error when using this module. Does anyone know the root cause?

When running with webpack
ERROR in node_modules/@aws-amplify/api/lib/types/index.d.ts(45,21): error TS2709: Cannot use namespace 'DocumentNode' as a type.

AOT build error
ERROR in node_modules/@aws-amplify/api/lib/types/index.d.ts(45,21): error TS2709: Cannot use namespace 'DocumentNode' as a type.
node_modules/aws-amplify-angular/dist/src/components/xr/sumerian-scene-component/sumerian-scene.component.core.d.ts(14,16): error TS2709: Cannot use namespace 'AmplifyUI' as a type.
node_modules/aws-amplify-angular/dist/src/components/xr/sumerian-scene-component/sumerian-scene-loading.component.core.d.ts(6,16): error TS2709: Cannot use namespace 'AmplifyUI' as a type.
node_modules/aws-amplify-angular/dist/src/components/xr/sumerian-scene-component/sumerian-scene.component.ionic.d.ts(5,16): error TS2709: Cannot use namespace 'AmplifyUI' as a type.

angular: 7.1.3
typescript: 3.16
aws-amplify: 1.1.17
aws-amplify-angular: 2.14

@haverchuck haverchuck added investigating This issue is being investigated API Related to REST API issues labels Dec 17, 2018
@haverchuck
Copy link
Contributor

#2365 related

manueliglesias added a commit to manueliglesias/aws-amplify that referenced this issue Dec 17, 2018
- Add type guard for DocumentNode
- Refactor `getGraphqlOperationType`

Fixes aws-amplify#2365
Fixes aws-amplify#2362
@ghost ghost added the review label Dec 17, 2018
@hoang-innomize
Copy link
Author

hoang-innomize commented Dec 18, 2018

After adding @types/graphql, I got another error related to AmplifyUI. So for now I have to use an older version 1.1.10

@hoang-innomize
Copy link
Author

hoang-innomize commented Jan 7, 2019

Does anyone know how to fix this error when building AOT build?

ERROR in node_modules/aws-amplify-angular/dist/src/components/xr/sumerian-scene-component/sumerian-scene.component.core.d.ts(14,16): error TS2709: Cannot use namespace 'AmplifyUI' as a type.
node_modules/aws-amplify-angular/dist/src/components/xr/sumerian-scene-component/sumerian-scene-loading.component.core.d.ts(6,16): error TS2709: Cannot use namespace 'AmplifyUI' as a type.
node_modules/aws-amplify-angular/dist/src/components/xr/sumerian-scene-component/sumerian-scene.component.ionic.d.ts(5,16): error TS2709: Cannot use namespace 'AmplifyUI' as a type.

I have reviewed the aws-amplify-angular project and cannot see any package dependency for @aws-amplify/ui

@fredmaiaarantes
Copy link

I have the same problem @hoang-innomizetech. Actually, all the times I try to use aws-amplify it's unstable. :(

@hoang-innomize
Copy link
Author

Yeah. Currently, it blocking us migrate to latest version to get some bug fixes :(

@hoang-innomize
Copy link
Author

@fredericomaia10 have you able to get this issue fixed?

@fredmaiaarantes
Copy link

@hoang-innomizetech unfortunately no.

@mrowles
Copy link
Contributor

mrowles commented Feb 13, 2019

@fredericomaia10 What's worse is that they parked their old repository and forced everyone over to this, and it barely works.

@temesxgn
Copy link

Any update on this? This is fix is urgent for me

@AxiomeCG
Copy link

Adding "@types/graphql": "0.13.0" to the package.json manually seems to fix it in my project for the moment.

@xaviertorgerson
Copy link

Just installing the latest @types/graphql with npm install @types/graphql did it for me.

@hoang-innomize
Copy link
Author

@xaviertorgerson @Exomus The DocumentNode issue can be fixed when installing the latest @types/graphql package, but when we are trying to build Angular AOT release, we are getting another error related to the AmplifyUI that I have reported above. This does not happen when we use aws-amplify-angular: 2.0.13 version.

@Christilut
Copy link

npm install @types/graphql doesn't work for me

I don't know how to get rid of this error right now

@tours232
Copy link

The fix seems to be to change the api/lib/types/index.d.ts line to the following because there is nothing in the graphql/language/ast file to import. I'm assuming the graphql dependency changed their code and ended up breaking this somehow?

import { DocumentNode } from 'graphql'

See https://github.com/graphql/graphql-js/blob/master/src/index.js.

@Christilut
Copy link

Current fix for me (which also removes the unused graphql dependency) is to use modular imports and not the whole amplify package. See #2401 (comment)

@hoang-innomize
Copy link
Author

Yeah, I upgraded to latest version and also uninstall the graphql dependency and it is worked. But it is only worked when we added the skipLibCheck: true to the tsconfig.json file, I think this fine as long as we don't want to check the type for lib dependencies.

After adding skipLibCheck option, the issue related to the AmplifyUI also fixed. So I am closing this ticket

@ghost ghost removed the review label Mar 28, 2019
@AdamShechter9
Copy link

just upgraded Angular6 project to 8 and having issues with AWS-Amplify-angular similar to @hoang-innomizetech above.
`ERROR in ../node_modules/aws-amplify-angular/dist/src/components/xr/sumerian-scene-component/sumerian-scene.component.core.d.ts:15:16 - error TS2709: Cannot use namespace 'AmplifyUI' as a type.

15 amplifyUI: AmplifyUI;
~~~~~~~~~
../node_modules/aws-amplify-angular/dist/src/components/xr/sumerian-scene-component/sumerian-scene-loading.component.core.d.ts:6:16 - error TS2709: Cannot use namespace 'AmplifyUI' as a type.

6 AmplifyUI: AmplifyUI;
~~~~~~~~~
../node_modules/aws-amplify-angular/dist/src/components/xr/sumerian-scene-component/sumerian-scene.component.ionic.d.ts:5:16 - error TS2709: Cannot use namespace 'AmplifyUI' as a type.

5 amplifyUI: AmplifyUI;
~~~~~~~~~
`

running:
`Angular CLI: 8.2.1
Node: 10.9.0
OS: darwin x64
Angular: 9.0.0-next.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package Version

@angular-devkit/architect 0.802.1
@angular-devkit/build-angular 0.802.1
@angular-devkit/build-optimizer 0.802.1
@angular-devkit/build-webpack 0.802.1
@angular-devkit/core 8.2.1
@angular-devkit/schematics 8.2.1
@angular/cdk 8.1.2
@angular/cli 8.2.1
@angular/material 8.1.2
@ngtools/webpack 8.2.1
@schematics/angular 8.2.1
@schematics/update 0.802.1
rxjs 6.5.2
typescript 3.5.3
webpack 4.38.0`

package dependencies:
"dependencies": { "@angular/animations": "^9.0.0-next.2", "@angular/cdk": "^8.1.2", "@angular/common": "^9.0.0-next.2", "@angular/compiler": "^9.0.0-next.2", "@angular/core": "^9.0.0-next.2", "@angular/forms": "^9.0.0-next.2", "@angular/material": "^8.1.2", "@angular/platform-browser": "^9.0.0-next.2", "@angular/platform-browser-dynamic": "^9.0.0-next.2", "@angular/router": "^9.0.0-next.2", "ajv": "^6.10.0", "amazon-cognito-auth-js": "^1.3.2", "angularx-qrcode": "^1.6.4", "aws-amplify": "^1.1.36", "@aws-amplify/ui": "1.0.23", "aws-amplify-angular": "^2.1.12", "core-js": "^2.4.1", "js-cookie": "^2.2.0", "rxjs": "^6.5.2", "rxjs-compat": "^6.0.0-rc.0", "tslib": "^1.10.0", "zone.js": "~0.9.1" },

node version 10.9.0

@AdamShechter9
Copy link

I temporarily fixed it and got it compiling by adding
// @ts-ignore
in a few locations in the node_module folder pointed out to me by the IDE.
but this could only be a temporary solution.

@hoang-innomize
Copy link
Author

@AdamShechter9 Did you try my solution as mentioned above

After adding skipLibCheck option, the issue related to the AmplifyUI also fixed. So I am closing this ticket

@amey91
Copy link

amey91 commented Oct 16, 2019

@hoang-innomizetech I would ideally not want to skip type check for dependencies. Can we get a better fix for this?

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API Related to REST API issues investigating This issue is being investigated
Projects
None yet
Development

Successfully merging a pull request may close this issue.