fix: panic on nil point on name check - #63967
Conversation
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Prevents parser panics when JSDoc overloads annotate anonymous default-exported functions.
Changes:
- Safely handles nil function names during JSDoc reparsing.
- Adds regression coverage for anonymous and named default exports.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tsc/internal/parser/reparser.go |
Guards nil names before identifier validation. |
tsc/internal/parser/parser_test.go |
Tests anonymous and named JSDoc overload declarations. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
This needs to be a regular compiler test, not a unit test
There was a problem hiding this comment.
thanks Jake Bailey (@jakebailey) , I have updated as such
Jake Bailey (jakebailey)
left a comment
There was a problem hiding this comment.
Verified that this test crashes without the fix. Thanks.
Why
In
checkNonIdentifierName, when name isnil, a panic occurs due to a nil pointer reference.Fixes #63750
How
Adds a check on the name, instead of passing it to
IsIdentifier. This prevents the panic when passing a nil pointer toIsIdentifier.Returns an early
nilif name is alreadynil.Tests
Verification
Backlogmilestone (required)mainbranchnpx hereby testnpx hereby lintnpx hereby check:format