はじめに
AWS CDK TypeScriptプロジェクトを作成し、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.
実施したこと
typescriptのバージョンを上げたら、ビルドできることが確認できた。
package.json
"typescript": "~3.9.7"
↓
package.json
"typescript": "^4.9.3"
最後に
参考にした文献を記す。
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/63431