相关文章推荐

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 ricardojbertolin, MariusRejdak, Mirco469, mrgrain, Raydir, ngg1, lili2311, mosikoo, ydg, raineorshine, and 2 more reacted with thumbs up emoji taobowen, chriszrc, and ajinkyk reacted with eyes emoji All reactions ricardojbertolin, tushar33, Raydir, lili2311, Salman-Abdulqadir, and chriszrc reacted with thumbs up emoji lili2311 reacted with hooray emoji All reactions

This is because #62968 use Template Literal Type to definite the type of _.get() which is not support below Typescript <= 4.1. We have discussed the solution in the pull request, and will fix or revert it asap. For now you can upgrade your Typescript version or you can override @type/lodash to old version.

I've tried both solutions from @Lluran and @Polinak87 without any luck.
Is there something I need to do to my yarn.lock to get these solutions to work?

Can you try deleting your lock file and your node modules folder and then re-running yarn (with either of the suggested solutions implemented in the package.json)

I've figured it out.
Turns out "overrides" doesn't work for yarn - if you're using yarn, the modification to package.json is

"resolutions": {
    "@types/lodash": "4.14.186"

Now my build is green again.
Thanks

Same problem using Testcafe with TypeScipt (includes lodash).

tried to update typeScript, but that did not work
downgrade to 4.14.186 works for me as a workaround (thanx for the tip)

Package.json:

"dependencies": {
		"node-fetch": "^2.6.7",
		"testcafe": "^1.19.0"
	"devDependencies": {
		"@types/node-fetch": "^2.6.1",
		"@types/lodash": "4.14.186"
          

I merged #63025 that should use previous version of definitions for TS <= 4.1, 4.14.188 should be published soon.

However generally speaking, DefinitelyTyped only checks and guarantees compatibility with TS versions listed here https://github.com/microsoft/DefinitelyTyped-tools/blob/master/packages/typescript-versions/src/index.ts#L65, and everything below 4.1 is considered unsupported. So updating TypeScript is the best solution.

With TypeScript v5 released, everything below 4.2 is considered unsupported by DefinitelyTyped, and it seems a <=4.1 fallback that I added to 4.14.188 was removed (for good if you ask me) because of failing merge checks instead of being updated to be a fallback for TS versions <=4.2.

Minimal supported TS v4.3 is already two minor versions into string template literals support, lack of which causes this compilation issue. I'd say, it's unlikely a support for older versions will be restored and maintained.

Two solutions here are either to update typescript to a version that supports string template literals (>= 4.1) or to lock @types/lodash resolution to either <=4.14.186 or 4.14.188

Hello, same issue since 17 April. "typescript": "4.0.8", "@types/lodash": "^4.14.186", I changed the version today to 4.14.186 from 4.14.194. but still fails.

Hi, i temporarily solved the problem adding "@types/lodash": "4.14.192" in dev dependencies and overriding third dependencies using overrides in package.json as stated in some comments above. Hope it helps
"overrides": {
"@types/lodash": "4.14.192"

Hello, same issue since 17 April. "typescript": "4.0.8", "@types/lodash": "^4.14.186", I changed the version today to 4.14.186 from 4.14.194. but still fails.

Hi, i temporarily solved the problem adding "@types/lodash": "4.14.192" in dev dependencies and overriding third dependencies using overrides in package.json as stated in some comments above. Hope it helps "overrides": { "@types/lodash": "4.14.192" },

Have tried this. it's not working. Which version of typescript you are using?

Hello, same issue since 17 April. "typescript": "4.0.8", "@types/lodash": "^4.14.186", I changed the version today to 4.14.186 from 4.14.194. but still fails.

Hi, i temporarily solved the problem adding "@types/lodash": "4.14.192" in dev dependencies and overriding third dependencies using overrides in package.json as stated in some comments above. Hope it helps "overrides": { "@types/lodash": "4.14.192" },

Have tried this. it's not working. Which version of typescript you are using?

I am using "typescript": "~4.0.2" as part of an angular 10 project. Did you delete node_modules and packege-lock.json before running npm install again?

we still get same the error. @types/lodash/common/object.d.ts:2051:54 - error TS1005: ';' expected.
Can you help us please?
Node 14.16.0, npm 6.14.11
Yarn version : 1.22.18

package.json file
"dependencies": {
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",

"devDependencies": {
    "@types/lodash": "^4.14.186",
    "@types/lodash-es": "^4.17.7",
    "typescript": "~4.0.2",
          

Just by importing the lodash, I got this:

node_modules/@types/lodash/common/common.d.ts:194:15 - error TS2589: Type instantiation is excessively deep and possibly infinite.
194     interface Object<T> extends LoDashImplicitWrapper<T> {
                  ~~~~~~
node_modules/@types/lodash/common/common.d.ts:206:15 - error TS2430: Interface 'ObjectChain<T>' incorrectly extends interface 'LoDashExplicitWrapper<T>'.
  The types returned by 'entries().pop()' are incompatible between these types.
    Type 'CollectionChain<string | T[keyof T]>' is missing the following properties from type 'ObjectChain<[string, any]>': assign, assignIn, assignInWith, assignWith, and 11 more.
206     interface ObjectChain<T> extends LoDashExplicitWrapper<T> {
                  ~~~~~~~~~~~
Found 2 errors in the same file, starting at: node_modules/@types/lodash/common/common.d.ts:194

Reproducing this error

  • ./package.json
  • "dependencies": { "lodash": "^4.17.21" "devDependencies": { "@types/lodash": "^4.14.195", "typescript": "^5.1.3"
  • ./tsconfig.json
  • "compilerOptions": { "esModuleInterop": true
  • ./index.ts
  • import lodash from 'lodash';

    Then:

    npm i
    npx tsc

    i removed all the "@types/lodash" library and re-added it in the devDependencies secion of the package.json with the version : "4.14.186", Pay attention to have it without the ^. It is important. I think you can do it like this npm install --save-dev --save-exact @types/lodash@4.14.186.

    I also added the tag "overrides": {
    "@types/lodash": "4.14.186"} in the package.json. To be checked but i think the last step is not mandatory.

    But again very important is to have the exact version, without the ^.

    I face the same challenge and tried @flavian-ioan approach with no luck.
    Here is my package.json file:

    "name": "typescript", "version": "1.0.0", "main": "app.js", "license": "MIT", "devDependencies": { "@types/lodash": "4.14.186", "typescript": "5.1.3" "overrides": { "@types/lodash": "4.14.186"

    still having this error! example repo here: https://github.com/adccb/tcli/tree/types/lodash

    let me know if you need any more info, but here's everything i thought might be relevant:

    error text

    > tcli@1.0.0 build
    > tsc --outDir dist/ src/index.ts
    node_modules/@types/lodash/common/common.d.ts:194:15 - error TS2589: Type instantiation is excessively deep and possibly infinite.
    194     interface Object<T> extends LoDashImplicitWrapper<T> {
                      ~~~~~~
    node_modules/@types/lodash/common/common.d.ts:206:15 - error TS2430: Interface 'ObjectChain<T>' incorrectly extends interface 'LoDashExplicitWrapper<T>'.
      The types returned by 'entries().pop()' are incompatible between these types.
        Type 'CollectionChain<string | T[keyof T]>' is missing the following properties from type 'ObjectChain<[string, any]>': assign, assignIn, assignInWith, assignWith, and 11 more.
    206     interface ObjectChain<T> extends LoDashExplicitWrapper<T> {
                      ~~~~~~~~~~~
    Found 2 errors in the same file, starting at: node_modules/@types/lodash/common/common.d.ts:194
    

    version numbers

    typescript@5.1.3
    @types/lodash@4.14.186
    lodash@4.17.21
    node@16.20.0
              

    Our issue will be fixed in the next version. I tried to adjust the code in node_module following this guide in issue #54542, and it can build normally.

    Seeing lines 194 and 206.

    Or we can workaround by putting "skipLibCheck": true into tsconfig.json when waiting for the patch.

    On my end, I still use TypeScript v5.0.4, and @types/lodash v4.14.195.

     
    推荐文章