typescript version: 4.5.2
lodash version: 4.17.21
npm run build
tsc && react-scripts build
node_modules/@types/lodash/common/object.d.ts:1026:46 - error TS1005: '?' expected.
1026 : K extends `${infer N extends number}` ? T[N] <br/>
~
node_modules/@types/lodash/common/object.d.ts:1031:46 - error TS1005: '?' expected.
1031 : K extends `${infer N extends number}` ? T[N] <br/>
~
node_modules/@types/lodash/common/object.d.ts:1041:46 - error TS1005: '?' expected.
1041 : K extends `${infer N extends number}` <br/>
~
Found 3 errors.
typescript version: 4.5.2
lodash version: 4.17.21
npm run build
tsc && react-scripts build
node_modules/@types/lodash/common/object.d.ts:1026:46 - error TS1005: '?' expected.
1026 : K extends `${infer N extends number}` ? T[N] <br/>
~
node_modules/@types/lodash/common/object.d.ts:1031:46 - error TS1005: '?' expected.
1031 : K extends `${infer N extends number}` ? T[N] <br/>
~
node_modules/@types/lodash/common/object.d.ts:1041:46 - error TS1005: '?' expected.
1041 : K extends `${infer N extends number}` <br/>
~
Found 3 errors.
Share
Improve this question
edited Jun 28, 2024 at 14:26
Rahul Sharma
10.1k1 gold badge19 silver badges40 bronze badges
asked Jun 28, 2024 at 14:19
ankit giriankit giri
5286 silver badges13 bronze badges
3
- 2 There is an issue opened for @types/lodash. The only suggested fix at this moment - to use @types/[email protected] – Sergey Sosunov Commented Jun 28, 2024 at 14:24
- After changing the version of lodash got new error for ansi-regex lib. internal/modules/cjs/loader.js:1102 throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath); ^ Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: node_modules/ansi-regex/index.js require() of /node_modules/ansi-regex/index.js from node_modules/renderkid/node_modules/strip-ansi/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. – ankit giri Commented Jun 28, 2024 at 14:49
- Y suddenly getting this issue, we didn't changed our build configuration recently – Ramesh_D Commented Jul 5, 2024 at 4:02
5 Answers
Reset to default 10Use lodash version 4.17.5 works for me.
I am using typescript version 4.6.4 and lodash version 4.17.5.
Uninstall the current version (4.17.6) and reinstall 4.17.5 version
npm uninstall @types/lodash
npm install @types/[email protected]
Then, the ng build should work
try this
"@types/lodash": "4.14.168"
Finally ,It works like a charm ( "typescript": "4.1.5")
I faced the exact same issue.
Two problems I have:
- Lodash below version 4.17.20 has a critical security issue. So, downgrading is not an option.
- Also, I can't update typescript to version 5 because of some old modules in my project...
My solution (=compromise) was to update Typescript to version 4.7.4 and the error disappeared.
Upgrade typescript
to v5+.
Apart from this, if you're using any bundlers (e.g., Rollup, Webpack), don't forget to upgrade their TypeScript-related packages as well.
I had to upgrade rollup-plugin-ts
.
The solution which worked for him.
- typescript version at 4.7.2.
- Added new dependency of @types/lodash at 4.17.5 version.