Open hg-pyun opened 9 months ago
https://codesandbox.io/s/competent-star-g4nqnp?file=/src/App.tsx
import { entries, fromEntries, groupBy, map, pipe, reduce } from "@fxts/core"; import "./styles.css"; type DataSet = { status: Status; count: number; }; enum Status { Todo = "TODO", InProgress = "IN_PROGRESS", Done = "DONE" } const data: Array<DataSet> = [ { status: Status.Todo, count: 0 }, { status: Status.InProgress, count: 0 } ]; export default function App() { pipe( data, map((item) => { return { progress: Status.Done, count: item.count }; }), groupBy((item) => item.progress), entries, map(([progress, values]) => { return [ progress, reduce((acc, cur) => acc + cur.count, 0, values) // <-- Type Error: values ] as const; }), fromEntries ); return null; }
TypeScript Inference is not working.
TypeScript Inference works.
@fxts/core@0.14.0: fine. @fxts/core@0.15.0: bug occur.
Maybe #199 side effect.
@hg-pyun
First If you change the function which inner reduce below, you can use it. but I think improvement is needed.
reduce
reduce((acc:number, cur:{count:number}) => acc + cur.count, 0, values)
Bug Report
π» Code
https://codesandbox.io/s/competent-star-g4nqnp?file=/src/App.tsx
π Actual behavior
TypeScript Inference is not working.
π Expected behavior
TypeScript Inference works.
Version Information
@fxts/core@0.14.0: fine. @fxts/core@0.15.0: bug occur.
Maybe #199 side effect.