Typescript Define Type With Function In R