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

Lodash omit unset #25522

Merged
merged 15 commits into from May 18, 2018
Merged

Lodash omit unset #25522

merged 15 commits into from May 18, 2018

Conversation

aj-r
Copy link
Contributor

@aj-r aj-r commented May 4, 2018

Fixes #25382, fixes #25361, fixes #25365. See discussion in those bugs.

Also fixes incorrect FP types for the partial function.

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes:
  • Increase the version number in the header if appropriate. N/A
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }.

@typescript-bot typescript-bot added this to Waiting for Reviewers in Pull Request Status Board May 4, 2018
@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Awaiting reviewer feedback labels May 4, 2018
@typescript-bot
Copy link
Contributor

typescript-bot commented May 4, 2018

@aj-r Thank you for submitting this PR!

🔔 @bczengel @chrootsu @stepancar @Ailrun @e-cloud @thorn0 @jtmthf @DomiR @typicode @niieani - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot typescript-bot moved this from Waiting for Reviewers to Needs Author Attention in Pull Request Status Board May 4, 2018
@typescript-bot
Copy link
Contributor

typescript-bot commented May 4, 2018

@aj-r The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@typescript-bot typescript-bot moved this from Needs Author Attention to Waiting for Reviewers in Pull Request Status Board May 5, 2018
@typescript-bot typescript-bot moved this from Waiting for Reviewers to Needs Author Attention in Pull Request Status Board May 5, 2018
@typescript-bot
Copy link
Contributor

typescript-bot commented May 5, 2018

@aj-r The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@typescript-bot
Copy link
Contributor

@aj-r I haven't seen anything from you in a while and this PR currently has problems that prevent it from being merged. The PR will be closed tomorrow if there aren't new commits to fix the issues.

@typescript-bot
Copy link
Contributor

@aj-r The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@typescript-bot typescript-bot moved this from Needs Author Attention to Waiting for Reviewers in Pull Request Status Board May 12, 2018
Copy link
Contributor Author

@aj-r aj-r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I needed to trim down the tests a bunch, otherwise the build fails due to lack of memory. This happens even without the changes from this PR, so I think it's caused by some change in TS 2.9.

Anyway, trimming down the tests make this PR a bit hard to read, so I've tried to highlight the significant changes to lodash-tests.ts. All changes in other files (common.d.ts, object.d.ts, fp.d.ts, generate-fp.ts`) are significant as well.

@@ -2860,15 +2860,23 @@ declare module "../index" {
*/
omit<T extends AnyKindOfDictionary>(
object: T | null | undefined,
...paths: PropertyPath[]
...paths: Array<Many<PropertyName>>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is technically the same as before, but I thought Many<PropertyName> better reflected how the value is being used.

@@ -5396,7 +5161,7 @@ fp.now(); // $ExpectType number

_.chain("abc").get(1); // $ExpectType LoDashExplicitWrapper<string>
_.chain("abc").get(["0"], "_");
_.chain([42]).get(0, -1); // $ExpectType LoDashExplicitWrapper<number | undefined>
_.chain([42]).get(0, -1); // ExpectType LoDashExplicitWrapper<number>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was failing even on the default branch (probably due to a bug fix in TS2.9) so I had to disable the $ExpectType.

@@ -5788,24 +5538,24 @@ fp.now(); // $ExpectType number
const dictionary: _.Dictionary<AbcObject> = anything;
const numericDictionary: _.NumericDictionary<AbcObject> = anything;

_.omit(obj, "a"); // $ExpectType Partial<AbcObject>
_.omit(obj, "a"); // ExpectType Pick<AbcObject, "b" | "c"> // NOTE: ExpectType disabled because it fails in TS2.4
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test the new omit overload

fp.unset("a.b")(object); // $ExpectType boolean
fp.unset(["a", "b"])(object); // $ExpectType boolean

fp.unset("a.b", object); // $ExpectType { a: { b: string; c: boolean; }; }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FP's version of unset returns an object, not a boolean.

_.propertyOf({}); // $ExpectType (path: Many<PropertyName>) => any
_({}).propertyOf(); // $ExpectType LoDashImplicitWrapper<(path: Many<PropertyName>) => any>
_.chain({}).propertyOf(); // $ExpectType LoDashExplicitWrapper<(path: Many<PropertyName>) => any>
_.propertyOf({}) as (path: _.Many<_.PropertyName>) => any;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests were also failing on the default branch - looks like TS 2.9 splits PropertyName into string | number | symbol, but earlier versions do not, so the $ExpectType does not work in this case.

@typescript-bot typescript-bot moved this from Waiting for Reviewers to Review in Pull Request Status Board May 17, 2018
@typescript-bot typescript-bot added the Unmerged The author did not merge the PR when it was ready. label May 17, 2018
@typescript-bot
Copy link
Contributor

typescript-bot commented May 17, 2018

A definition owner has approved this PR ⭐️. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait. Thank you for your contribution to DefinitelyTyped!

Copy link
Contributor

@niieani niieani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me.

@typescript-bot typescript-bot moved this from Review to Check and Merge in Pull Request Status Board May 17, 2018
@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. Merge:Express and removed Awaiting reviewer feedback Unmerged The author did not merge the PR when it was ready. labels May 17, 2018
@rbuckton rbuckton merged commit 011afe6 into DefinitelyTyped:master May 18, 2018
@rbuckton
Copy link
Collaborator

Thanks for the contribution!

@typescript-bot typescript-bot removed this from Check and Merge in Pull Request Status Board May 18, 2018
@aj-r aj-r deleted the lodash-omit-unset branch July 26, 2018 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Owner Approved A listed owner of this package signed off on the pull request. Popular package This PR affects a popular package (as counted by NPM download counts).
Projects
None yet
4 participants