aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.39k stars 2.11k forks source link

Angular v17 and latest typescript having issues with @aws-amplify sub-dependencies #13260

Open simonramosb opened 2 months ago

simonramosb commented 2 months ago

Before opening, please confirm:

JavaScript Framework

Angular

Amplify APIs

GraphQL API

Amplify Version

v6

Amplify Categories

api

Backend

Other

Environment information

``` # Put output below this line Angular v17.3.4 node 18 lts typescript: 5.4.5 aws-amplify: 6.0.28 ```

Describe the bug

I'm migrating an app made with ionic and angular, to newer versions (v17, where i need typescript >= 5.2.0). Everything seems fine, until i built.

I had lots of these errors, with the @aws-amply/plugin-types package. (Detailed in log output section)

Error: node_modules/@aws-amplify/plugin-types/lib/function_resources.d.ts:1:40 - error TS2307: Cannot find module 'aws-cdk-lib/aws-lambda' or its corresponding type declarations

I found out that is a dependency of @aws-amplify/data-schema-types yarn.lock screenshot: image

If i rollback to typescript 4.9.5 everything works fine, but its not compatible with angular v17.

Thanks in advance for reading my issue, any ideas or possible hacks will be highly appreciated :)

Expected behavior

Correct build

Reproduction steps

  1. yarn install
  2. ionic serve // ng serve // ng build

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line ``` [ng] Error: node_modules/@aws-amplify/plugin-types/lib/auth_resources.d.ts:1:23 - error TS2307: Cannot find module 'aws-cdk-lib/aws-iam' or its corresponding type declarations. [ng] [ng] 1 import { IRole } from 'aws-cdk-lib/aws-iam'; [ng] ~~~~~~~~~~~~~~~~~~~~~ [ng] [ng] [ng] Error: node_modules/@aws-amplify/plugin-types/lib/auth_resources.d.ts:2:142 - error TS2307: Cannot find module 'aws-cdk-lib/aws-cognito' or its corresponding type declarations. [ng] [ng] 2 import { CfnIdentityPool, CfnIdentityPoolRoleAttachment, CfnUserPool, CfnUserPoolClient, CfnUserPoolGroup, IUserPool, IUserPoolClient } from 'aws-cdk-lib/aws-cognito'; [ng] ~~~~~~~~~~~~~~~~~~~~~~~~~ [ng] [ng] [ng] Error: node_modules/@aws-amplify/plugin-types/lib/backend_secret_resolver.d.ts:1:27 - error TS2307: Cannot find module 'constructs' or its corresponding type declarations. [ng] [ng] 1 import { Construct } from 'constructs'; [ng] ~~~~~~~~~~~~ [ng] [ng] [ng] Error: node_modules/@aws-amplify/plugin-types/lib/backend_secret_resolver.d.ts:3:29 - error TS2307: Cannot find module 'aws-cdk-lib' or its corresponding type declarations. [ng] [ng] 3 import { SecretValue } from 'aws-cdk-lib'; [ng] ~~~~~~~~~~~~~ [ng] [ng] [ng] Error: node_modules/@aws-amplify/plugin-types/lib/backend_stack_creator.d.ts:1:23 - error TS2307: Cannot find module 'aws-cdk-lib' or its corresponding type declarations. [ng] [ng] 1 import { Stack } from 'aws-cdk-lib'; [ng] ~~~~~~~~~~~~~ [ng] [ng] [ng] Error: node_modules/@aws-amplify/plugin-types/lib/construct_container.d.ts:1:27 - error TS2307: Cannot find module 'constructs' or its corresponding type declarations. [ng] [ng] 1 import { Construct } from 'constructs'; [ng] ~~~~~~~~~~~~ [ng] [ng] [ng] Error: node_modules/@aws-amplify/plugin-types/lib/function_resources.d.ts:1:40 - error TS2307: Cannot find module 'aws-cdk-lib/aws-lambda' or its corresponding type declarations. [ng] [ng] 1 import { CfnFunction, IFunction } from 'aws-cdk-lib/aws-lambda'; [ng] ~~~~~~~~~~~~~~~~~~~~~~~~ [ng] [ng] [ng] Error: node_modules/@aws-amplify/plugin-types/lib/resource_access_acceptor.d.ts:1:24 - error TS2307: Cannot find module 'aws-cdk-lib/aws-iam' or its corresponding type declarations. [ng] [ng] 1 import { Policy } from 'aws-cdk-lib/aws-iam'; [ng] ~~~~~~~~~~~~~~~~~~~~~ [ng] [ng] [ng] ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

cwomack commented 2 months ago

@simonramosb, thank you for opening this issue. Just to confirm, is this a Gen2 app that you're experiencing this in?

simonramosb commented 2 months ago

Hey @cwomack! Thanks for your reply. No, the last team used this library just for handling connections to an appsync endpoint. Why? I dont really know haha. I'm here just for the typescript version, cause i can't upgrade angular.

cwomack commented 3 days ago

@simonramosb, can you clarify if you are trying to create a Gen 2 app in this migration and do you have the aws-cdk-lib package under your dev dependencies (alternatively, you could share your package.json as well)?