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

dot-object pick should return any in stead of void (sent PR) #14319

Closed
2 tasks done
aredfox opened this issue Jan 28, 2017 · 2 comments
Closed
2 tasks done

dot-object pick should return any in stead of void (sent PR) #14319

aredfox opened this issue Jan 28, 2017 · 2 comments

Comments

@aredfox
Copy link
Contributor

aredfox commented Jan 28, 2017

  • I tried using the @types/dot-object package and had problems.
  • Mention the authors (see Definitions by: in index.d.ts) so they can respond.

Description: Function 'pick' shows in dot-object documentation to return a value - yet in the typings it has the return value :void.

I have used dot-object's pick a long time to get values from a given 'path/key' - like done in the documentation: var val = dot.pick('some.nested.value', obj); - but now when using this in TypeScript with the current typing it won't let me - as the return type is void.

I would like to suggest changing this to returnign type any - as when removing the value it is documented to return it as well before removing it. Hence I don't think (correct me if I'm wrong) there's need for an overload here.

       /**
         *
         * Pick a value from an object using dot notation.
         *
         * Optionally remove the value
         *
         * @param {String} path
         * @param {Object} obj
         * @param {Boolean} remove
         */
        pick(path: string, obj: any, remove?: boolean): any;

Reference to dot-object documentation: https://github.com/rhalff/dot-object#pickremove-a-value-using-dot-notation

var obj = {
 some: {
   nested: {
     value: 'Hi there!'
   }
 }
};

var val = dot.pick('some.nested.value', obj);
console.log(val);

Hi there!
aredfox added a commit to aredfox/DefinitelyTyped that referenced this issue Jan 28, 2017
- See issue DefinitelyTyped#14319

Function 'pick' returns is documented to always return a value. Before it's return type was :void, I'm sending this proposal as :any would fix this issue.
Reference to dot-object documentation: https://github.com/rhalff/dot-object#pickremove-a-value-using-dot-notation
@aredfox
Copy link
Contributor Author

aredfox commented Jan 28, 2017

Created PR for this, if this could help #14320

@aredfox aredfox changed the title dot-object pick should return any in stead of void dot-object pick should return any in stead of void (sent PR) Jan 28, 2017
aredfox added a commit to aredfox/electron-starter that referenced this issue Jan 28, 2017
- Changed @types/dot-object manually in node_modules - see DefinitelyTyped/DefinitelyTyped#14319 - so beware when compiling and .pick() function's return type typings haven't changed from :void to :any yet.
annich-MS pushed a commit to annich-MS/DefinitelyTyped that referenced this issue Feb 21, 2017
- See issue DefinitelyTyped#14319

Function 'pick' returns is documented to always return a value. Before it's return type was :void, I'm sending this proposal as :any would fix this issue.
Reference to dot-object documentation: https://github.com/rhalff/dot-object#pickremove-a-value-using-dot-notation
@orta orta closed this as completed Jun 7, 2021
@orta
Copy link
Collaborator

orta commented Jun 7, 2021

Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the @types modules in DefinitelyTyped.

To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the definitely-typed channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants