Skip to content

fix: avoid treating await in jsdoc as top-level await #877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025

Conversation

a-tarasyuk
Copy link
Contributor

@a-tarasyuk a-tarasyuk commented May 17, 2025

Fixes #874


parseJSDocIdentifierName uses newIdentifier, which may flag await identifier as a top-level declaration. @sandersn should this be suppressed when parsing JSDoc?

result := p.newIdentifier(text)

func (p *Parser) newIdentifier(text string) *ast.Node {
p.identifierCount++
id := p.factory.NewIdentifier(text)
if text == "await" {
p.statementHasAwaitIdentifier = true
}
return id
}

@jakebailey jakebailey requested a review from sandersn May 17, 2025 00:40
@sandersn
Copy link
Member

The trailing p.statementHasAwaitIdentifier = saveHasAwaitIdentifier should be the right code to suppress it; it should discard the true value before parseToplevelStatement examines it and adds the statement to the possibleAwaitSpans.

@sandersn sandersn added this pull request to the merge queue May 20, 2025
Merged via the queue into microsoft:main with commit 656029e May 20, 2025
23 checks passed
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.

JSDoc parsing breaks when declaring a property named await
2 participants