I am a full-stack developer, mainly working with Typescript. I enjoy learning functional programming languages on the side. Fan of video games, basketball, reading and hip hop music
Here's an example I used in a PR at work the other day to advocate against using lodash now that we've moved to Typescript:
import*asAfrom"fp-ts/lib/ReadonlyArray";import{flow}from"fp-ts/lib/function";importfpfrom"lodash/fp";// This compiles no problem! Somehow lodash is happy to compose a function// which returns a number with a function which accepts `null | { name: string }`// myFn is typed as `(...args: any[]) => any` as well, which can cause other// problems later down the lineconstmyFn=fp.pipe((x:number[])=>x.reduce((accum,val)=>accum+val,0),(banana:null|{name:string})=>"haha I can compose random functions together"+JSON.stringify(banana),);// This errors with `Type 'number' is not assignable to type '{ name: string; } | null'`constmyFn1=flow((x:number[])=>x.reduce((accum,val)=>accum+val,0),(banana:null|{name:string})=>"haha I can compose random functions together"+JSON.stringify(banana),);
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here's an example I used in a PR at work the other day to advocate against using lodash now that we've moved to Typescript: