Description
TypeScript Version: 3.2.0-dev.20181101
Search Terms: shebang comment
Code
#! node
/** text */
const v = 1;
Expected behavior:
Hovering v
should show the JSDoc comment's text.
Actual behavior:
Doesn't show the JSDoc. In fact ts.forEachLeadingCommentRange
and ts.forEachTrailingCommentRange
aborts when encountering the shebang, so no comments are recognised.
There are a few places where this issue occurs (the reason is always the same):
- using the compiler API to visit or get comments
- retrieving JSDoc of a declaration
- declaration emitter looking for
// @internal
comments
Playground Link: https://agentcooper.github.io/typescript-play/#code/MQQgBAdg9gJgpgKAPQCoVgC5wB4bCpBAYyggGc8A3MAXjAEYBuIA
Dropping in an empty statement after the shebang fixes the issue: https://agentcooper.github.io/typescript-play/#code/MQQgBAdg9gJgpgKANwIPQCp1gC5wB7ZjqoIDGUEAzoQG5gC8YAjEkA
I'd like to submit a PR to fix the scanner if you accept this bug.