I have a method in my component which is strictly used for removing duplicate values from an array.
const removeDuplicateScenarios = (scenariosList: Scenario[]): Scenario[] => {
return _.filter(scenariosList, el => _.filter(scenariosList, e => e.id === el.id).length === 1);
};
However, I want to completely make this reusable as possible wherein I dont define the types explicitly but does the job.
const removeDuplicateValues = (values: []): [] => {
return _.filter(values, el => _.filter(values, e => e.id === el.id).length === 1);
};
Is any the only type I can use over here?
However, I get these errors:
TS2322: Type 'never[]' is not assignable to type '[]'.
Types of property 'length' are incompatible.
Type 'number' is not assignable to type '0'.
Please advice.