jashkenas/coffeescript

Comment moves inside of object

STRd6 opened this issue · 1 comments

STRd6 commented

When trying to add a JSDoc comment to an object that is an argument to a function the comment gets moved to the first key of the object. I would expect the comment to be on the first key if there is no explicit { but it seems to attach to the first key even when the explicit { is present after the comment.

f a, ###* @type {Something} ### {
  key: {}
}

Actual:

// Generated by CoffeeScript 2.6.1
f(a, {
  /** @type {Something} */key: {}
});

Expected:

// Generated by CoffeeScript 2.6.1
f(a, /** @type {Something} */ {
  key: {}
});

Same note as #5415 (comment). Comments are stowaways on the nearest “real” token, and because of the rewriter { tokens are sometimes not part of the normal stream (since they’re often inserted later, because of implicit objects). I’d love to support JSDoc comments as much as possible.