Fix false positive TS8030 for JSDoc @type on optional interface methods - #64052
Open
종윤 (jyx-07) wants to merge 1 commit into
Open
Fix false positive TS8030 for JSDoc @type on optional interface methods#64052종윤 (jyx-07) wants to merge 1 commit into
종윤 (jyx-07) wants to merge 1 commit into
Conversation
| c.checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, c.getReturnTypeFromAnnotation(node)) | ||
| if node.FunctionLikeData().FullSignature != nil { | ||
| if c.getContextualCallSignature(c.getTypeFromTypeNode(node.FunctionLikeData().FullSignature), node) == nil { | ||
| if c.getContextualCallSignature(c.removeMissingOrUndefinedType(c.getTypeFromTypeNode(node.FunctionLikeData().FullSignature)), node) == nil { |
Author
There was a problem hiding this comment.
Added tsc/testdata/tests/cases/compiler/jsdocOptionalMethodFullSignature.ts, covering both the optional indexed-access signature (fixed) and an arity-mismatch case (still correctly reports TS8030).
When a JSDoc @type annotation on a function resolves through an optional interface member (e.g. Example['method'] where method is optional), the resolved type includes | undefined. Three call sites in checker.go fed that raw union directly into signature-lookup helpers that don't handle unions with undefined, producing a false TS8030 diagnostic and an implicit any for the parameter. Strip the undefined via the existing removeMissingOrUndefinedType helper at all three sites before signature resolution, matching the pattern already used elsewhere in the checker for the same class of problem.
종윤 (jyx-07)
force-pushed
the
fix/jsdoc-optional-method-8030
branch
from
August 27, 2026 12:00
d2477a6 to
f980e3c
Compare
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #63754.
When a JSDoc Type (@type) annotation on a function resolves through an
optional interface member (e.g.
Example['method']wheremethodisoptional), the resolved type includes
| undefined. Three call sitesin checker.go fed that raw union directly into signature-lookup
helpers that don't handle unions with undefined, producing a false
TS8030 diagnostic and an implicit
anyfor the parameter.Fix: apply the existing
removeMissingOrUndefinedTypehelper atall three sites before signature resolution, matching the pattern
already used elsewhere in the checker for the same class of problem.
Added a regression test (
jsdocOptionalMethodFullSignature.ts)covering both the fixed case and an arity-mismatch case that must
still correctly report TS8030.
Verified: