Repository navigation
Fix intrinsic jsx tag name case in getTypeAtLocation - #3802
Conversation
There was a problem hiding this comment.
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.GetTypeOfSymbolAtLocationwhen thelocationidentifier is a JSX tag name, JSX attribute name, or part of a JSX namespaced name. - Add a fourslash regression test that performs
hoveron 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. |
|
Doesn't something like this mean that in an example like the following: foo.bar/**/requesting quick info on |
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. |
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.