Skip to content

Failing builds in Typescript project using aws-amplify/api since this line was added #2365

@nihakue

Description

@nihakue

Describe the bug
Since the addition of the linked line, our builds have been failing with:

<truncated>/@aws-amplify/api/lib/types/index.d.ts
ERROR in <truncated>/node_modules/@aws-amplify/api/lib/types/index.d.ts(1,30):
TS7016: Could not find a declaration file for module 'graphql/language/ast'. '<truncated>/node_modules/graphql/language/ast.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/language/ast';`

We are using [email protected] and @aws-amplify/[email protected]. Our tsconfig.json is:

{
  "compilerOptions": {
    "baseUrl": ".",
    "outDir": "build/dist",
    "module": "esnext",
    "target": "es5",
    "lib": ["es6", "dom"],
    "sourceMap": true,
    "allowJs": true,
    "jsx": "react",
    "moduleResolution": "node",
    "rootDir": "src",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": false,
    "typeRoots": [
      "./typings/", "./node_modules/@types/"
    ]
  },
  "exclude": [
    "node_modules",
    "build",
    "scripts",
    "acceptance-tests",
    "webpack",
    "jest",
    "src/setupTests.ts"
  ]
}

I can work-around the issue with the following steps

  1. Add @types/graphql as a dev dependency
  2. Change typsecript lib ( tsconfig.json: compilerOptions.lib: ["esnext", "dom"])

At the moment, we aren't using graphql, so the graphql dependency is a little unfortunate.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new typescript app (we use create-react-app-ts)
  2. Add a dependency on @aws-amplify/api
  3. Try to build
  4. See error

Expected behavior
When not using graphql, I shouldn't have to use graphql types.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Ubuntu
  • Browser: Any
  • Version Any

Metadata

Metadata

Labels

APIRelated to REST API issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions