coffeescript icon indicating copy to clipboard operation
coffeescript copied to clipboard

Comment moves inside of object

Open STRd6 opened this issue 3 years ago • 1 comments

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: {}
});

STRd6 avatar Apr 28 '22 00:04 STRd6

Same note as https://github.com/jashkenas/coffeescript/issues/5415#issuecomment-1109194355. 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.

GeoffreyBooth avatar Apr 28 '22 04:04 GeoffreyBooth