Description
Status: RESOLVED
Projects using TypeScript <4.2 (like the ones created with cdk init
are failing to compile due to a transitive dependency introducing a breaking change. This issue does not affect you if you are using a recent TypeScript version.
Possible Solutions
Any of the following options will work around this issue:
- Pin
@types/babel__traverse
to7.18.2
indevDependencies
package.json
{
"devDependencies": {
"@types/babel__traverse": "7.18.2"
}
}
-
Upgrade the TypeScript version to TS
>=4.2
-
Create new apps with a AWS CDK CLI of version
>=2.52.1
or>=1.81.1
or projen
Describe the bug
A recent release of @types/babel__traverse
(7.18.3) updated the minimum typescript version to 4.2
. If you have CDK apps created with cdk init
and not upgraded the TypeScript version, the build will fail.
$npm ls @types/babel__traverse
cdk-app@0.1.0
├── @types/babel__traverse@7.18.2
├─┬ jest@27.5.1
│ └─┬ @jest/core@27.5.1
│ └─┬ jest-snapshot@27.5.1
│ └── @types/babel__traverse@7.18.2 deduped
└─┬ ts-jest@27.1.5
└─┬ babel-jest@27.5.1
├─┬ @types/babel__core@7.1.20
│ └── @types/babel__traverse@7.18.2 deduped
└─┬ babel-preset-jest@27.5.1
└─┬ babel-plugin-jest-hoist@27.5.1
└── @types/babel__traverse@7.18.2 deduped
Expected Behavior
No error.
Current Behavior
When trying to build a typescript app you get the error message:
$ npm run build
node_modules/@types/babel__traverse/index.d.ts:68:50 - error TS1005: ']' expected.
68 export type ArrayKeys<T> = keyof { [P in keyof T as T[P] extends any[] ? P : never]: P };
~~
node_modules/@types/babel__traverse/index.d.ts:68:53 - error TS1005: ';' expected.
68 export type ArrayKeys<T> = keyof { [P in keyof T as T[P] extends any[] ? P : never]: P };
~
node_modules/@types/babel__traverse/index.d.ts:68:58 - error TS1005: ';' expected.
68 export type ArrayKeys<T> = keyof { [P in keyof T as T[P] extends any[] ? P : never]: P };
~~~~~~~
node_modules/@types/babel__traverse/index.d.ts:68:70 - error TS1011: An element access expression should take an argument.
68 export type ArrayKeys<T> = keyof { [P in keyof T as T[P] extends any[] ? P : never]: P };
node_modules/@types/babel__traverse/index.d.ts:68:83 - error TS1005: ';' expected.
68 export type ArrayKeys<T> = keyof { [P in keyof T as T[P] extends any[] ? P : never]: P };
~
node_modules/@types/babel__traverse/index.d.ts:68:84 - error TS1128: Declaration or statement expected.
68 export type ArrayKeys<T> = keyof { [P in keyof T as T[P] extends any[] ? P : never]: P };
~
node_modules/@types/babel__traverse/index.d.ts:68:88 - error TS1128: Declaration or statement expected.
68 export type ArrayKeys<T> = keyof { [P in keyof T as T[P] extends any[] ? P : never]: P };
~
Found 7 errors.
Reproduction Steps
Step 1 - create a new CDK app
cdk init --language=typescript app
Step 2 - Try to build
npm run build
Additional Information/Context
No response
CDK CLI Version
<=2.52.0
<=1.18.0
Framework Version
No response
Node.js Version
14+
OS
any
Language
Typescript
Language Version
<4.2
Other information
No response
Activity
[-]@types/babel__traverse@7.18.3 breaks builds[/-][+]‼️ NOTICE: @types/babel__traverse@7.18.3 breaks builds[/+]fix(jsii): @types/babel__traverse@7.18.3 breaks builds (#2265)
fix(cli): typescript init templates fails with error in build step (#…
github-actions commentedon Nov 28, 2022
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
fix(cli): typescript init templates fails with error in build step (#…
[-]‼️ NOTICE: @types/babel__traverse@7.18.3 breaks builds[/-][+]‼️ @types/babel__traverse@7.18.3 breaks builds[/+]15 remaining items