question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript compiler errors using AWS-Amplify in a custom app

See original GitHub issue

Hello, I tried to convert my application from AppSyncSDK to Amplify but I have some compiler errors when I import it. The errors are:

  • node_modules/aws-amplify/lib/Cache/types/Cache.d.ts:38:15 - error TS2304: Cannot find name ‘Storage’.
  • node_modules/aws-amplify/lib/Cache/types/Cache.d.ts:39:13 - error TS2304: Cannot find name ‘Cache’.
  • node_modules/aws-amplify/lib/Common/RNComponents/index.d.ts:6:29 - error TS2304: Cannot find name ‘Storage’.
  • node_modules/aws-amplify/lib/Common/ServiceWorker/ServiceWorker.d.ts:23:29 - error TS2304: Cannot find name ‘ServiceWorker’.
  • node_modules/aws-amplify/lib/Common/StorageHelper/index.d.ts:2:30 - error TS2304: Cannot find name ‘Storage’.

I tried to start from scratch with very simple program. The repro app include only 3 files

package.json:

{
  "name": "aws_amplify_test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@types/node": "^8.10.18",
    "aws-amplify": "0.4.4",
    "typescript": "^2.9.1"
  }
} 

tsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "moduleResolution": "node",
        "target": "es6",
        "lib": [ "es6"],
        "sourceMap": true,
        "noImplicitAny": false,
        "outDir": "./dist/"
    },
  "include": [
    "./**/*"
  ],
  "exclude": [
    "node_modules",
    "./**/*.spec.ts"
  ]
}

app.ts:

import Amplify from 'aws-amplify';
console.log('Hello world');

When I run TSC compiler I retrieve the previous errors. if It is my fault, could you provide a very simple typescript app with aws-amplify?

Repro in the zip file attached aws_amplify_test.zip

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

18reactions
vallyscodecommented, Sep 20, 2018

Just in case someone else has such problem in nodejs. Solution is to add “dom” to lib in tsconfig.json so that compiler can find definitions.

10reactions
HintikkaKimmocommented, May 2, 2019

Just in case someone else has such problem in nodejs. Solution is to add “dom” to lib in tsconfig.json so that compiler can find definitions.

This turned out to cause new issues in my environment. Having dom as lib trickered host of new errors in the newest version of React-Native typings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

deploy angular app on AWS amplify gives build failed errors
node_modules/@ngtools/webpack/src/ivy/index.js): Error: Emit Error: Failed to initialize Angular compilation - Cannot read properties of ...
Read more >
aws amplify typescript support - JodiStory
Typescript Compiler errors from @aws-amplify/auth #4200 Deploy a Next.js 13 app to AWS with Amplify Hosting Now, lets register a callback ...
Read more >
Using the API.ts Typescript types generated by AWS Amplify
We explore using Typescript with AWS Amplify API in React Native, with a particular focus on the types that AWS Amplify generates into...
Read more >
API (GraphQL) - Client code generation - AWS Amplify Docs
The amplify codegen types [--nodownload] command generates GraphQL types for Flow and typescript and Swift class in an iOS project. This command downloads ......
Read more >
Building Lambda functions with TypeScript
To transpile your TypeScript code, set up a compiler such as esbuild or Microsoft's TypeScript compiler ( tsc ) , which is bundled...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found