tc39 / proposal-error-stacks

ECMAScript Proposal, specs, and reference implementation for Error.prototype.stack / System.getStack
https://tc39.github.io/proposal-error-stacks/
MIT License
168 stars 13 forks source link

typeof(Error.prototype.stack) == "object"? #40

Closed rdking closed 3 years ago

rdking commented 3 years ago

Unless I misread the spec document, the result of (new Error).stack will be an object. Currently, albeit non-standard it is always a string where implemented. Won't that break anything existing that does any stack inspection? Wouldn't it be more backwards compatible to spec it as a string, then define a separate property or function to return the object the spec describes?

theScottyJam commented 3 years ago

I don't think that's the case.

Over here it states that Error.prototype.stack is a getter, and returns the result of the getStackString operation, which in turn gives back a string.

ljharb commented 3 years ago

Error.prototype.stack being a non-string would break the web, which is why the current spec has it outputting a string.

Error.getStack or the equivalent would be what outputs an object structure.