jashkenas / jashkenas/coffeescript

Comment moves inside of object

Open
#5,417 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
CoffeeScript
Stars
16.6k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

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.

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

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

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

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the CoffeeScript example from the issue and inspect the compiler entry points responsible for comments and object arguments. Trace how the comment is attached during compilation, then verify that the generated JavaScript places it before the object and preserves the existing behavior for comments without an explicit opening brace.

Written by the indexing model from the issue text.

Assessment

Tech stack
coffeescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.