Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nojvek opened this issue Jan 30, 2016 · 5 comments
Labels
Bug A bug in TypeScript ES6 Relates to the ES6 Spec Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it
Milestone

Comments

@nojvek
Copy link
Contributor

nojvek commented Jan 30, 2016

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);
    }
};
@DanielRosenwasser
Copy link
Member

This might be related to #6433.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript ES6 Relates to the ES6 Spec labels Feb 1, 2016
@mhegazy mhegazy added this to the TypeScript 2.0 milestone Feb 24, 2016
@mhegazy mhegazy unassigned yuit Jun 8, 2016
@mhegazy mhegazy modified the milestones: TypeScript 2.1, TypeScript 2.0 Jun 8, 2016
@mhegazy mhegazy self-assigned this Sep 29, 2016
@mhegazy mhegazy modified the milestones: Future, TypeScript 2.1 Sep 29, 2016
@Hotell
Copy link

Hotell commented Mar 24, 2017

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

@nojvek
Copy link
Contributor Author

nojvek commented Mar 24, 2017 via email

@grundmanise
Copy link

@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

@RyanCavanaugh RyanCavanaugh added the Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it label Feb 23, 2024
@RyanCavanaugh
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript ES6 Relates to the ES6 Spec Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it
Projects
None yet
Development

No branches or pull requests

7 participants