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 ... again #2474

Closed
jgoeglein opened this issue Jun 8, 2021 · 12 comments · Fixed by #2537
Closed

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

jgoeglein opened this issue Jun 8, 2021 · 12 comments · Fixed by #2537
Assignees
Labels
bug This issue is a bug.

Comments

@jgoeglein
Copy link
Contributor

Describe the bug

Same as #1919 - twas fixed in aws-sdk 3.4.0, but seems to be back since 3.10.0.

@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.

Your environment

SDK version number

3.10.0+

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

All

Details of the browser/Node.js/ReactNative version

node v10.24.1
tsc 3.7.5

Steps to reproduce

Observed behavior

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

tsc

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

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

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


Found 2 errors.
lab_63.js
import {
TranslateClient,
TranslateTextCommand,
TranslateTextCommandInput,
TranslateTextCommandOutput,
} from "@aws-sdk/client-translate";

const client: TranslateClient = new TranslateClient({ region: "us-west-2" });

const params: TranslateTextCommandInput = {
SourceLanguageCode: "en",
TargetLanguageCode: "fr",
Text: "Hello, World!",
};
const command = new TranslateTextCommand(params);

const translate = async () => {
const data: TranslateTextCommandOutput = await client.send(command);
console.log(data);
};

translate();
package.json
{
"name": "environment",
"version": "1.0.0",
"description": "",
"main": "lab_63.js",
"scripts": {
  "build": "tsc",
  "test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
  "@aws-sdk/client-translate": "3.10.0"
},
"devDependencies": {
  "@types/node": "^15.12.2",
  "typescript": "3.7.5"
}
}
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

@jgoeglein jgoeglein added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 8, 2021
@ZultanH
Copy link

ZultanH commented Jun 21, 2021

I am also experiencing this issue, would be good if this gets resolved quickly

@fsmawi
Copy link

fsmawi commented Jun 21, 2021

I'm experiencing the same issue with Typescript v3.9.5.

tsc

node_modules/@aws-sdk/credential-provider-web-identity/dist/types/fromWebToken.d.ts:110:19 - error TS1005: ']' expected.

110     [K in keyof T as `${Uncapitalize<string & K>}`]: T[K];
                      ~~
node_modules/@aws-sdk/credential-provider-web-identity/dist/types/fromWebToken.d.ts:110:49 - error TS1005: '(' expected.

110     [K in keyof T as `${Uncapitalize<string & K>}`]: T[K];
                                                    ~
node_modules/@aws-sdk/credential-provider-web-identity/dist/types/fromWebToken.d.ts:127:1 - error TS1160: Unterminated template literal.

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

92 export declare type UserAgentPair = [name: string, version?: string];
                                            ~
node_modules/@aws-sdk/types/dist/types/util.d.ts:92:60 - error TS1005: ',' expected.

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

@skorfmann
Copy link

Same here with Typescript v3.9.10

@TreTuna
Copy link
Contributor

TreTuna commented Jun 25, 2021

I'm also seeing this with TS v3.6.4

@TreTuna
Copy link
Contributor

TreTuna commented Jun 26, 2021

I figured out the issue, which seems to be twofold:

  1. The /dist/types/ts3.4/ directory generated by the prepublishOnly script doesn't seem to get published.
    You can see this by:
  • Run npm pack @aws-sdk/types to download the tarball of the most current version
  • unpack the tarball and look in the dist/types folder
    image
  1. typesVersions is pointing to the wrong place:
    Currently:
"typesVersions": {
    "<4.0": {
      "types/*": [
        "types/ts3.4/*"
      ]
    }
  },

Should be:

    "<4.0": {
      "dist/types/*": [
        "dist/types/ts3.4/*"
      ]
    }
  },

I verified this by running prepublishOnly myself, moving that into the node_modules/@aws-sdk/types/dist/types directory in my application, updating the typesVersions configuration to add dist/, and running a build on my consuming library.

#2 is simple to fix and I'm trying to debug prepublishOnly right now. Hopefully will figure something out there and will submit a PR (unless someone gets to it before me).

@TreTuna
Copy link
Contributor

TreTuna commented Jun 26, 2021

v3.10.0 has the folder published, but starting at v3.12.0 it is no longer there. It was between those releases that downlevel-dts dist/types dist/types/ts3.4 was moved from postbuild to prepublishOnly and from that point they stopped getting published to npm. It would seem that this is not working

@trivikr
Copy link
Member

trivikr commented Jun 30, 2021

The PR which moved running downlevel-dts in prepublishOnly step #2218

In the PR it was verified that:

  • The ts3.4 folder is not created after yarn build:all
  • The ts3.4 folder is created after ./node_modules/.bin/lerna run prepublishOnly

@trivikr
Copy link
Member

trivikr commented Jun 30, 2021

Noticed the following error from our release log:

npm WARN lifecycle @aws-sdk/[email protected]~prepublishOnly: cannot run in wd @aws-sdk/[email protected] yarn build && downlevel-dts dist/types dist/types/ts3.4 (wd=.)

@trivikr
Copy link
Member

trivikr commented Jun 30, 2021

The issue appear to be with our release script, where prepublisOnly script is run from different directory (.), instead of from root of the package being published.

@TreTuna
Copy link
Contributor

TreTuna commented Jul 13, 2021

The types are now there, however, the second issue I listed still exists: #2474 (comment)

typesVersions is pointing to the wrong place:
Currently:

"typesVersions": {
    "<4.0": {
      "types/*": [
        "types/ts3.4/*"
      ]
    }
  },

Should be:

    "<4.0": {
      "dist/types/*": [
        "dist/types/ts3.4/*"
      ]
    }
  },

I just opened a PR for this fix: #2579

@trivikr
Copy link
Member

trivikr commented Jul 14, 2021

Thank you @TreTuna for the PR!

The change was required to be done in codegen as well as all packages.

Your commit was picked and subsequent PRs were posted at:

@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 Jul 29, 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
Development

Successfully merging a pull request may close this issue.

6 participants