Skip to content
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

Fix 38219: signature helper works for optional function condition. #39672

Merged
merged 2 commits into from
Jul 22, 2020

Conversation

ShuiRuTian
Copy link
Contributor

@ShuiRuTian ShuiRuTian commented Jul 20, 2020

Fixes #38219

@ShuiRuTian
Copy link
Contributor Author

ShuiRuTian commented Jul 21, 2020

strange, how to add test?

/// <reference path='fourslash.ts'/>

//// interface Obj {
////     optionalMethod?: (current: any) => any;
//// };
////
//// const o: Obj = {
////   optionalMethod(/*1*/) {
////     return {};
////   }
//// };

verify.signatureHelp(
    {
        marker: "1",
        text: 'optionalMethod(current: any): any',
        parameterName: "current",
        parameterSpan: "current: any",
    },
);

This would pass in unfixed code.

@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Jul 21, 2020
@orta
Copy link
Contributor

orta commented Jul 21, 2020

Yeah, agree, doesn't look like using verify.completions({ marker: "1", includes: [{ name: "current"}]}) is useful for verifying this either.

I'll ask around internally.

Copy link
Contributor

@orta orta left a comment

Choose a reason for hiding this comment

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

@weswigham spotted the issue, your test wasn't using strict and so the optional-ness was dropped. I've pushed a test which fails on master and passes on this PR. Thanks!

@orta
Copy link
Contributor

orta commented Jul 22, 2020

Cool, thanks @ShuiRuTian

@orta orta merged commit e76d172 into microsoft:master Jul 22, 2020
@ShuiRuTian ShuiRuTian deleted the fix-38219 branch November 25, 2020 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

Signature help not working on optional methods
3 participants