You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would love it if I could re-use some defined function type without have to use a function expression. Function declarations should allow for a generic after the keyword function that defines it's arguments and return type.
Example:
typeFormatter=(s: string)=> `FORMATTED: ${s}.`
// today you have to use a function expressionconstfmt:Formatter=(str)=>{β¦}// ideally something like this is possiblefunction<Formatter>(str){β¦}
Allows for type re-use in places where function expressions are unnecessary.
Better ergonomics when you have interfaces that define functions.
Concise function overloads
The text was updated successfully, but these errors were encountered:
tbremer
changed the title
Suggestion: function declarations should have way to re-use established types.
Suggestion: function declarations should have way to reuse established types.
Jul 12, 2023
Suggestion
π Search Terms
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Would love it if I could re-use some defined function type without have to use a function expression. Function declarations should allow for a generic after the keyword
function
that defines it's arguments and return type.Example:
Playground link with sample code: https://www.typescriptlang.org/play?#code/PTAEHcHsFcBsBNS0gNwKagIYUwT1AC6SjxoDGsmAThgQBYCWAzqAGbQB2ZBDkHoTBgHMOmAtBoRgxOphQMOQwsWhMM2dlx59QaAB4AHGk0E7IVUDQC04KgwK06GUqwX3eHAHQAoELs9CngBcbJzcHgA8AHJ8UXCUAEawaBEAsrgAkhwOVKyYZGgA2gDk+docTMUAuiUMpNkMrLjVAHwtoHVoDU0AFACUoADeoIBkBKAAvt6a4Tqd3bj9Q6DAAFSjoCtgk36gu3u7AHoA-N7eZHxMBB31PE0ATCExHHGwiclpmdlouflFpTMVaq1G6NZpVdoAXlAiwh7WGq3WmwmvjA+32x1OChyeQKoHSWWxvyG3l2ZQ8TBCgxJezmt1wRxCPTqIUudkUABpdABbTAMWAMgQENlCAaw0AoSB1ADc1N2xjQBAFMPaEulssIaEuStFKsl8Blu0m4yAA
π Motivating Example
π» Use Cases
The text was updated successfully, but these errors were encountered: