Skip to content

Typescript 3.7.x breaking @aws-sdk/types #1919

@alexforsyth

Description

@alexforsyth

Describe the bug
@aws-sdk/types declares UserAgentPair.

export declare type UserAgentPair = [name: string, version?: string];

Pairs are not supported in Typescript 3.7.x
https://devblogs.microsoft.com/typescript/announcing-typescript-4-0/#labeled-tuple-elements.

Users running typescript < 4.0.0 cannot correctly get types.

SDK version number
3.3.0

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

Details of the browser/Node.js/ReactNative version
node v14.15.4

To Reproduce (observed behavior)

The following error is thrown for the code example give below:

$ yarn build
yarn run v1.22.5
$ tsc
node_modules/@aws-sdk/types/dist/cjs/util.d.ts:92:42 - error TS1005: ',' expected.

92 export declare type UserAgentPair = [name: string, version?: string];
                                            ~

node_modules/@aws-sdk/types/dist/cjs/util.d.ts:92:60 - error TS1005: ',' expected.

92 export declare type UserAgentPair = [name: string, version?: string];
                                                              ~


Found 2 errors.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
package.json
{
  "name": "test-ts-3.7",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "build": "tsc"
  },
  "dependencies": {
    "@aws-sdk/client-s3": "3.3.0"
  },
  "devDependencies": {
    "@types/node": "14.14.22",
    "typescript": "3.7.5"
  }
}
index.ts
import { S3 } from "@aws-sdk/client-s3";

(async () => {
  const region = "us-west-2";
  const client = new S3({ region });
  await client.listBuckets({});
})();
tsconfig.json
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true
  }
}

Expected behavior
No error is thrown when compiling client code with TypeScript version 3.7.x

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions