Skip to content

Enhancement: optimize tests of parameter type parser according to test coverage report #2296

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

Closed
JesseCodeBones opened this issue May 19, 2022 · 8 comments
Labels

Comments

@JesseCodeBones
Copy link
Contributor

Hi Guys,
I tried to enhance the test coverage, there is some missing part according to coverage report.
I might commit several commits or PRs under this issue, please let me know if it is not suitable.
Thank you.
Regards

@JesseCodeBones
Copy link
Contributor Author

Phase: 1
File: src/parser.ts
Functions: [parseTypeParameter, parseParameters]
PR: #2297

@JesseCodeBones
Copy link
Contributor Author

JesseCodeBones commented May 19, 2022

I found it could be a issue for test:

function extendsfunctiontype(this: ()=>void):void {}

the result is we get 1003 error as expected but we still can see it is compiled as below:
function extendsfunctiontype(): void {}
(that means it is included into AST now)

I am not sure if it is reasonable, because extends from anonymous function type is meaningless.
can you help to look at it? thank you.

@dcodeIO
Copy link
Member

dcodeIO commented May 19, 2022

The parser/compiler try to recover from errors that will ultimately cause compilation to fail, so more than one error can be diagnosed. Here, the recognizable parts of the AST are still produced during parsing, but their compilation is not attempted.

@JesseCodeBones
Copy link
Contributor Author

JesseCodeBones commented May 26, 2022

@dcodeIO
Hi DcodeIO,
I tried to fix the test coverage to 90.37%.

image

and I find a small issue here.
at parser.js line 2097, parseClassMember function.
the error message should be private modifier cannot be used here instead of protected modifier cannot be used here
Can you advice is we can fix it in this PR or we need another issue and another PR? thank you.

        } else if (flags & CommonFlags.PRIVATE) {
          this.error(
            DiagnosticCode._0_modifier_cannot_be_used_here,
            tn.range(accessStart, accessEnd), "protected"
          ); // recoverable
        }

@dcodeIO
Copy link
Member

dcodeIO commented May 26, 2022

I guess this can be one PR, along the lines of "fix: X and add additional tests". Does this sound OK?

@JesseCodeBones
Copy link
Contributor Author

@dcodeIO
OK, I will prepare it, thank you.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in one week if no further activity occurs. Thank you for your contributions!

@JesseCodeBones
Copy link
Contributor Author

@dcodeIO
Hi dcodeIO,
I noticed this issue has been closed, do we have plan to enhancement this part? Thank you.
Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants