Skip to content

Conversation

@Andarist
Copy link
Contributor

fixes #55394

@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Aug 16, 2023
const typeNode = getEffectiveTypeAnnotationNode(declaration);
if (typeNode) {
inferTypes(inferenceContext.inferences, getTypeFromTypeNode(typeNode), getTypeAtPosition(context, i));
const source = addOptionality(getTypeFromTypeNode(typeNode), /*isProperty*/ false, hasQuestionToken(declaration));
Copy link
Member

Choose a reason for hiding this comment

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

hasQuestionToken(declaration) isn't going to do the right thing for jsdoc optional parameters - instead, use the catch-all isOptionalDeclaration.

Copy link
Contributor Author

@Andarist Andarist Aug 16, 2023

Choose a reason for hiding this comment

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

👍 pushed out the appropriate change (and a test case)

@weswigham weswigham merged commit 3b49ce9 into microsoft:main Aug 16, 2023
@Andarist Andarist deleted the fix/infer-from-annotated-optional-params branch August 16, 2023 21:51
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type inference changed for callbacks with optional parameters

3 participants