aws-sdk-js-v3 icon indicating copy to clipboard operation
aws-sdk-js-v3 copied to clipboard

Typescript 3.5.x breaking @aws-sdk/types

Open trivikr opened this issue 4 years ago • 4 comments

Describe the bug

@aws-sdk/types uses AsyncGenerator https://github.com/aws/aws-sdk-js-v3/blob/80a80941a150e36f416bb24cc6c137f674c1dbdf/packages/types/src/pagination.ts#L3-L6

The customer code throws "Cannot find name 'AsyncGenerator'" when trying to compile with TS <3.6.x

$ tsc
node_modules/@aws-sdk/types/types/ts3.4/pagination.d.ts:5:36 - error TS2304: Cannot find name 'AsyncGenerator'.

5 export declare type Paginator<T> = AsyncGenerator<T, T, unknown>;
                                     ~~~~~~~~~~~~~~
Found 1 error.

Your environment

SDK version number

@aws-sdk/[email protected]

Is the issue in the browser/Node.js/ReactNative?

N/A

Details of the browser/Node.js/ReactNative version

Not relevant but, Node.js v14.15.4

Steps to reproduce

package.json
{
  "scripts": {
    "build": "tsc"
  },
  "dependencies": {
    "@aws-sdk/client-s3": "3.4.1"
  },
  "devDependencies": {
    "@types/node": "14.14.25",
    "typescript": "3.5.3"
  }
}
tsconfig.json
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true
  }
}
index.ts
import { S3Client } from "@aws-sdk/client-s3";

Observed behavior

yarn build
yarn run v1.22.10
warning package.json: No license field
$ tsc
node_modules/@aws-sdk/types/types/ts3.4/pagination.d.ts:5:36 - error TS2304: Cannot find name 'AsyncGenerator'.

5 export declare type Paginator<T> = AsyncGenerator<T, T, unknown>;
                                     ~~~~~~~~~~~~~~


Found 1 error.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected behavior

No error is thrown when compiling client code with TypeScript version 3.5.x

Additional context

Follow-up to https://github.com/aws/aws-sdk-js-v3/issues/1919

trivikr avatar Feb 11 '21 17:02 trivikr

One workaround is to unblock is to enable skipLibCheck in TSConfig of application code. This would skip type checking of all declaration files though.

trivikr avatar Feb 11 '21 20:02 trivikr

This happens as the AsyncGenerator was added in es2018.asyncgenerator which was release in TypeScript 3.6

  • Code: https://github.com/microsoft/TypeScript/blob/v3.6-beta/lib/lib.es2018.asyncgenerator.d.ts
  • PR which added it https://github.com/microsoft/TypeScript/pull/32578

trivikr avatar Feb 11 '21 20:02 trivikr

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

github-actions[bot] avatar Mar 10 '22 00:03 github-actions[bot]

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

github-actions[bot] avatar Mar 03 '24 00:03 github-actions[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

github-actions[bot] avatar Mar 23 '24 00:03 github-actions[bot]