Skip to content

Conversation

@gabritto
Copy link
Member

Fixes #2290.

We were scanning into an AST node in getTokenAtPosition, basically because in this JSDoc case:

/**
 * @type {{
 * 'string-property': boolean;
 */*$*/ identifierProperty: boolean;
 * }}
 */
var someVariable;

identifierProperty's position does not include what would typically be its leading trivia. So the positions between the starting * and identifierProperty effectively don't belong to any node or token in the AST, but getTokenAtPosition operated under the assumption that this was impossible, and therefore that we should scan and find a non-tree token in between * and identifierProperty.

I added code to explicitly track what the next AST node is (nodeAfterLeft) whenever we update the scanner starting position (left), so we can then enforce the invariant of scanning only in between AST nodes.

@jakebailey jakebailey mentioned this pull request Dec 13, 2025
@ahejlsberg
Copy link
Member

@gabritto See my comment here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash for completions after JSDoc * on line following string-named property signature

3 participants