Skip to content

TS: Fix extraction of default-exported classes and functions #2093

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 4 commits into from
Oct 8, 2019

Conversation

asger-semmle
Copy link
Contributor

Fixes #2051. I'm also running an evaluation just to be sure.

@asger-semmle asger-semmle added the JS label Oct 7, 2019
@asger-semmle asger-semmle requested a review from a team as a code owner October 7, 2019 15:56
@ghost
Copy link

ghost commented Oct 8, 2019

LGTM, but @erik-krogh should be the one to sign off on this.

@ghost ghost assigned erik-krogh Oct 8, 2019
@ghost
Copy link

ghost commented Oct 8, 2019

(the change-notes are missing)

Copy link
Contributor

@erik-krogh erik-krogh left a comment

Choose a reason for hiding this comment

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

LGTM. (But as Esben mentioned, change-notes are missing, I'll approve once those are in place)

However a comment.

Your fix is to change a ClassDeclaration to a ClassExpression in the case of a default export, because that is what the existing JavaScript extractor does.
However, as one can find out by using AST explorer, it is actually a ClassDeclaration.

So the real fix would be to change the JavaScript extractor to extract a ClassDeclaration, and then get that to work with all the existing code.

However, that is a fix for the backlog.
And I think this fix is good enough that it won't bite us later.

@asger-semmle
Copy link
Contributor Author

However, as one can find out by using AST explorer, it is actually a ClassDeclaration.

That doesn't really matter though. Our AST was (initially) modelled after estree in which a ClassDeclaration must have an identifier. I checked the spec and AFAICT there is no semantic difference.

@asger-semmle
Copy link
Contributor Author

Evaluation on typescript.slugs looks fine.

@semmle-qlci semmle-qlci merged commit c8e5be7 into github:master Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LGTM.com - false positive - TypeScript
3 participants