Skip to content

Add optionality to @typedef's @property #872

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 16, 2025

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented May 16, 2025

Just like @param optionality (about 70 lines later at line 140) except that it's added to a synthetic property signature, so no need to check for an existing ?.

Also a driveby style improvement.

Just like @param optionality except that it's added to a synthetic
property signature, so no need to check for an existing `?`.
@Copilot Copilot AI review requested due to automatic review settings May 16, 2025 13:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for marking @typedef properties as optional (via string= or bracketed syntax) by emitting a question token in the AST, and it removes outdated error baselines that expected missing-property errors for those cases.

  • Enhance the JSDoc reparser to produce a ? token for optional properties in typedefs
  • Remove old test baselines that asserted errors for missing optional properties

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff Remove old error expectations for optional props
testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.errors.txt Remove old error expectations for optional props
internal/parser/reparser.go Add logic to emit ? question token for optional JSDoc properties
Comments suppressed due to low confidence (2)

internal/parser/reparser.go:71

  • Add a brief comment explaining that bracketed or @type= expressions map to an optional property (?) in the emitted signature to aid future readers.
if member.AsJSDocPropertyTag().IsBracketed || member.AsJSDocPropertyTag().TypeExpression != nil && member.AsJSDocPropertyTag().TypeExpression.Type().Kind == ast.KindJSDocOptionalType {

testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff:1

  • The removal of the old error baseline tests for missing optional properties is correct, but consider adding new positive tests that verify no error is reported when optional properties are omitted.
diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.errors.txt.diff

@sandersn sandersn added this pull request to the merge queue May 16, 2025
Merged via the queue into microsoft:main with commit d056c7d May 16, 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.

None yet

2 participants