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

LoDashStatic.filter isn't working #2582

Closed
pocesar opened this issue Jul 29, 2014 · 1 comment
Closed

LoDashStatic.filter isn't working #2582

pocesar opened this issue Jul 29, 2014 · 1 comment

Comments

@pocesar
Copy link
Contributor

pocesar commented Jul 29, 2014

I have this class method: (using Typescript 1.0.1 and latest lodash type definitions)

        getSelected(type: string, one:boolean):void;
        getSelected(type: string, one:boolean):IDataItem[];
        getSelected(type, one:boolean = true):IDataItem {
            if (one) {
                return _.reduce<IDataItem, IDataItem>(sections[type], (current: IDataItem, p: IDataItem) => {
                    return p.selected === true ? p : current;
                }, void 0);
            } else {
                return _.filter<IDataItem>(sections[type], (p: IDataItem):boolean => {
                    return p.selected === true && p.enabled === true;
                });
            }
        }

it's giving me:

planner.ts(801,24): error TS2012: Cannot convert 'IDataItem[]' to 'IDataItem':
        Type 'IDataItem[]' is missing property 'name' from type 'IDataItem'.

for _.reduce, it works properly. sections[type] are IDataItem[]

@pocesar
Copy link
Contributor Author

pocesar commented Jul 30, 2014

not a problem with lodash, but from my lack of understanding typescript overloads

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

1 participant