Skip to content
This repository was archived by the owner on Sep 1, 2026. It is now read-only.

Fix intrinsic jsx tag name case in getTypeAtLocation - #3802

Merged
Gabriela Araujo Britto (gabritto) merged 2 commits into
mainfrom
gabritto/issue3638
May 11, 2026
Merged

Gabriela Araujo Britto (gabritto) merged 2 commits into
mainfrom
gabritto/issue3638

Conversation

@gabritto

@gabritto Gabriela Araujo Britto (gabritto) commented May 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #3638.
This was a bug in Strada as well.
We shouldn't be checking an identifier that is a tag name or an attribute name because that's not usually how we check those JSX nodes. I think we don't need this change for correctness if #3435 lands, but I think this may still be worth fixing.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a language-service regression where hovering a JSX intrinsic element could poison subsequent diagnostics with a spurious TS2304: Cannot find name 'div' (issue #3638), by preventing GetTypeOfSymbolAtLocation from treating JSX tag/attribute identifiers as normal identifier expressions for control-flow narrowing.

Changes:

  • Skip the control-flow-narrowing path in Checker.GetTypeOfSymbolAtLocation when the location identifier is a JSX tag name, JSX attribute name, or part of a JSX namespaced name.
  • Add a fourslash regression test that performs hover on an intrinsic JSX tag and then asserts diagnostics remain error-free.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/checker/checker.go Avoids invoking expression typing/narrowing for JSX tag/attribute identifiers in GetTypeOfSymbolAtLocation, preventing incorrect symbol/type caching effects.
internal/fourslash/tests/hoverThenDiagnosticsJsxIntrinsic_test.go Adds regression coverage for the hover-then-diagnostics sequence that previously produced spurious TS2304 on intrinsic JSX elements.

@gabritto
Gabriela Araujo Britto (gabritto) marked this pull request as ready for review May 11, 2026 20:19
@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented May 11, 2026 •

Copy link
Copy Markdown
Member

Doesn't something like this mean that in an example like the following:

foo.bar/**/

requesting quick info on bar before diagnostics are requested could report that bar is not defined?

Merged via the queue into main with commit 6eb79f4 May 11, 2026
21 checks passed
@gabritto
Gabriela Araujo Britto (gabritto) deleted the gabritto/issue3638 branch May 11, 2026 20:58
@gabritto

Copy link
Copy Markdown
Member Author

Doesn't something like this mean that in an example like the following:

foo.bar/**/

requesting quick info on bar before diagnostics are requested could report that bar is not defined?

GetTypeOfSymbolAtLocation already handles this case like this:

if ast.IsIdentifier(location) || ast.IsPrivateIdentifier(location) {
			if ast.IsRightSideOfQualifiedNameOrPropertyAccess(location) {
				location = location.Parent
			}
			...

so in those property access-like cases, we already adjust location to be the parent.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot find name html element.

4 participants