Search code examples
javascriptlambdatypescriptarrow-functions

Is it possible to create a named "fat-arrow" lambda in typescript?


Using the traditional function syntax, it's possible to create named functions inline.

var fn = function myName(arg) {
    // whatever
};
// fn.name === "myName"

Can names be specified in typescript using the lambda syntax?

var fn = (arg) => {
    // whatever
};
// fn.name not set

Solution

  • Doesn't look like you can do that, as the spec doesn't cover it, only at the end under "deferred" it states "Optional leading Identifier for named arrow function expressions."