3 ms·
I like TypeScript's syntax, but I think the way function types are declared is ugly. If you have a function from A to B, you have to declare its type as t
by frankpf 8y ago
I like TypeScript's syntax, but I think the way function types are declared is ugly.
If you have a function from A to B, you have to declare its type as
type MyFunction = (arg1: A) => B
instead of
type MyFunction = A => B
Here's that syntax applied to the example from GP:
function call<TS extends any[], R>(fn: (...args: TS) => R, ...args: TS): R { return fn(...args); }
vs.
function call<TS extends any[], R>(fn: ...TS => R, ...args: TS): R { return fn(...args); }
- eppsilon 8y agoThe syntax is probably meant to differentiate between a function expression and a function type declaration.