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

@types/underscore error TS2322 for _.chain after upgrade to v1.9 #36308

Closed
smileLilith opened this issue Jun 20, 2019 · 7 comments · Fixed by #46306, #45994, #45763, #46035 or #46120
Closed

@types/underscore error TS2322 for _.chain after upgrade to v1.9 #36308

smileLilith opened this issue Jun 20, 2019 · 7 comments · Fixed by #46306, #45994, #45763, #46035 or #46120

Comments

@smileLilith
Copy link

After upgrade of @types/underscore from v1.8.20 to v1.9.0 all usages of _.chain in my angular project were broken. For example

const arr1: string[] = ['z', 'x', 'y'], query = 'z';
let arr2: string[] = ['a', 'b', 'c'];
...
arr2 = _.chain(arr1)
      .union(arr2)
      .without(query)
      .value()

has returned

error TS2322: Type 'string' is not assignable to type 'string[]'

It seems it was caused by changes done in this commit.

@regevbr, @DanielRosenwasser was this expected? If yes, what is upgrade path?

@smileLilith smileLilith changed the title @types/underscore after upgrade to v1.9 _.chain returns error @types/underscore error TS2322 for _.chain after upgrade to v1.9 Jun 20, 2019
@regevbr
Copy link
Contributor

regevbr commented Jun 20, 2019

I'm sorry for that. I will get right on it.
Thanks for reporting!

@smileLilith
Copy link
Author

No worries, thank you

@regevbr
Copy link
Contributor

regevbr commented Jun 20, 2019

The changes made at #36230 caused it
@jgonggrijp the changes we just made caused a breaking chnage and I verified it in the test of the library.
As I mentioned in the PR - I will need to revise all the methods under the _.Chain interface so they will not break existing code.
Any suggestions for now?

@jgonggrijp
Copy link
Contributor

@regevbr I have nothing to add to what you already said. Add tests that replicate the problem, then revise the code until all tests pass again.

And then wait until the next issue comes up... it's a fact of life.

@regevbr
Copy link
Contributor

regevbr commented Jun 20, 2019

@jgonggrijp I already did it and the fix takes a second but I found myself revising the entire library as almost 90% of the _Chain interface is completely wrong (even from before the change). I also noticed that there are some missing methods declarations and dome deprecated ones.
I want to finish the complete revision of the library but it is going to take a few days for us to ping pong on the review as it will be a big one

@jgonggrijp
Copy link
Contributor

@regevbr Would it be doable for you to submit a PR that only fixes the current issue first? I don't mind reviewing twice, and while I agree it's important for the Chain interface to be correct, I'd say that newly introduced bugs are a bit more urgent to fix than long-existing ones.

@regevbr
Copy link
Contributor

regevbr commented Jun 20, 2019

@jgonggrijp sure coming right up

RyanCavanaugh pushed a commit that referenced this issue Jul 1, 2019
* [@types/underscore] Fix #36308 - underscore has bad chain typings fix only for function 'map' (#36319)

* [@types/underscore] Fix #36308 - underscore has bad chain typings fix only for function 'map' (#36319)
Add more test and applay changes form review

* [@types/underscore] Fix #36308 - underscore has bad chain typings fix only for function 'map' (#36319)
 - Add more test
 - revert part of typings for function

* Comment part of test with currently didn't pass
iRON5 pushed a commit to iRON5/DefinitelyTyped that referenced this issue Aug 13, 2019
iRON5 pushed a commit to iRON5/DefinitelyTyped that referenced this issue Aug 13, 2019
…ain typi… (DefinitelyTyped#36510)

* [@types/underscore] Fix DefinitelyTyped#36308 - underscore has bad chain typings fix only for function 'map' (DefinitelyTyped#36319)

* [@types/underscore] Fix DefinitelyTyped#36308 - underscore has bad chain typings fix only for function 'map' (DefinitelyTyped#36319)
Add more test and applay changes form review

* [@types/underscore] Fix DefinitelyTyped#36308 - underscore has bad chain typings fix only for function 'map' (DefinitelyTyped#36319)
 - Add more test
 - revert part of typings for function

* Comment part of test with currently didn't pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment