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

Semicolon after method body causes "TypeError: Cannot read property 'getJsDocTags' of undefined" #2098

Closed
1 of 4 tasks
RomainMuller opened this issue Oct 9, 2020 · 1 comment · Fixed by #2163
Closed
1 of 4 tasks
Assignees
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort language/typescript Related to Typescript code module/compiler Issues affecting the JSII compiler needs-triage This issue or PR still needs to be triaged. p2

Comments

@RomainMuller
Copy link
Contributor

RomainMuller commented Oct 9, 2020

🐛 Bug Report

Affected Languages

  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...)

What is the problem?

An innocuous semicolon after a method body causes the compiler to trip trying to read its documentation string (this is so weird):

The full error message is:

[ERROR] jsii/compiler - Error during type model analysis: TypeError: Cannot read property 'getJsDocTags' of undefined

A likely trivial reproduction of this is:

export class Example {
  /** Method!! */
  public method(): void {
    console.log("whelp");
  }; // <-- this is the problematic semicolon
}

This was found to trip @nija-at over at aws/aws-cdk#10521 (via: https://github.com/aws/aws-cdk/blob/de58a8b5bbce2157cba80c668116138386057036/packages/%40aws-cdk/aws-apigateway/lib/domain-name.ts#L164)

@RomainMuller RomainMuller added bug This issue is a bug. effort/small Small work item – less than a day of effort needs-triage This issue or PR still needs to be triaged. p2 module/compiler Issues affecting the JSII compiler language/typescript Related to Typescript code labels Oct 9, 2020
@RomainMuller RomainMuller self-assigned this Oct 9, 2020
RomainMuller added a commit that referenced this issue Oct 22, 2020
When a trailing semicolon was left after a method body, the compiler
would choke with a `TypeError` due to attempting to read the JSDoc tags
of an `undefined` symbol.

This checks for this particular case and ignores the "class member" that
is represented by the dangling semicolon; and emits a diagnostic message
informing users the token could be removed.

Fixes #2098
@mergify mergify bot closed this as completed in #2163 Oct 22, 2020
mergify bot pushed a commit that referenced this issue Oct 22, 2020
#2163)

When a trailing semicolon was left after a method body, the compiler
would choke with a `TypeError` due to attempting to read the JSDoc tags
of an `undefined` symbol.

This checks for this particular case and ignores the "class member" that
is represented by the dangling semicolon; and emits a diagnostic message
informing users the token could be removed.

Fixes #2098



---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort language/typescript Related to Typescript code module/compiler Issues affecting the JSII compiler needs-triage This issue or PR still needs to be triaged. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant