Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
alexforsyth opened this issue Jan 15, 2021 · 6 comments · Fixed by #1943 or smithy-lang/smithy-typescript#266
Closed

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

alexforsyth opened this issue Jan 15, 2021 · 6 comments · Fixed by #1943 or smithy-lang/smithy-typescript#266
Assignees
Labels
bug This issue is a bug.

Comments

@alexforsyth
Copy link
Contributor

alexforsyth commented Jan 15, 2021

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

@trivikr
Copy link
Member

trivikr commented Jan 21, 2021

This issue would be fixed by using downlevel-dts to create type definition files which support TS 3.4 or later.

@trivikr
Copy link
Member

trivikr commented Jan 21, 2021

@ohana54
Copy link

ohana54 commented Jan 29, 2021

@trivikr I upgraded to 3.4.0 and it still doesn't work - I use TS 3.9.7, while labeled tuples were added in 4.x. It's probably due to this condition:

If I change it to <= it works fine.

@trivikr
Copy link
Member

trivikr commented Jan 29, 2021

I upgraded to 3.4.0 and it still doesn't work - I use TS 3.9.7, while labeled tuples were added in 4.x. It's probably due to this condition:

I'll create a separate issue specific to 3.9.7 for tracking.
I'll also update downlevel-dts README https://github.com/sandersn/downlevel-dts#usage

@ohana54
Copy link

ohana54 commented Jan 29, 2021

Thanks! I can open a PR for the readme.
EDIT: sandersn/downlevel-dts#51

@github-actions
Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators Feb 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug.
Projects
None yet
3 participants