microsoft/TypeScript

function definitions in object shorthand should generate named function definitions rather than anonymous functions

nojvek opened this issue · 5 comments

Btw brilliant work on getting object shorthand

let logger = {
   log(str){
      console.log(str)
   }
};

generates

var logger = {
    log: function (str) {
        console.log(str);
    }
};

since it becomes an anonymous function, it doesn't stand out in stack traces. Emitting this would make debugging and stack traces a lot nicer.

var logger = {
    log: function log (str) {
        console.log(str);
    }
};

This might be related to #6433.

I don't think this is a bug? It's how it should work according to MDN, but I may be wrong ofc https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions

@Hotell Is right in regards to how it should be transpiled. Their names should be inferred due to the runtime semantics which are defined in the specs

This doesn't seem like an important scenario for modern JS development - folks can either target ES6 which is supported basically everywhere, or use an alternate transpiler with stricter adherence semantics if this is important for their scenario.