Skip to content

Comments

JS: Add common interface between TypeExpr and JSDocTypeExpr#1257

Merged
xiemaisi merged 19 commits intogithub:masterfrom
asger-semmle:jsdoc
Apr 29, 2019
Merged

JS: Add common interface between TypeExpr and JSDocTypeExpr#1257
xiemaisi merged 19 commits intogithub:masterfrom
asger-semmle:jsdoc

Conversation

@asger-semmle
Copy link
Contributor

Adds a class TypeAnnotation with TypeExpr and JSDocTypeExpr as subclasses.

It has some methods for common tasks but currently doesn't a mirror hierarchy of the two class hierarchies. I'm not sure how much value we get out of modelling this hierarchy.

For now I'd like to feedback on whether this design is something we can all agree on.

The return type of getTypeAnnotation() and friends have changed to TypeAnnotation, which is a breaking change since this is not an ASTNode. I've copied over some of the predicates from ASTNode to reduce the impact. Short of deprecating and renaming all of them, or changing JSDocTypeExpr to be an ASTNode, I think it's unavoidable but low impact.

Still needs an upgrade script, and an evaluation is running in case changing the rootdef of getEnclosingStmt and friends have catastrophic consequences.

@asger-semmle asger-semmle added JS WIP This is a work-in-progress, do not merge yet! labels Apr 16, 2019
@asger-semmle asger-semmle requested a review from a team as a code owner April 16, 2019 14:07
Copy link

@xiemaisi xiemaisi left a comment

Choose a reason for hiding this comment

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

Design LGTM; the potential breakage seems hard to avoid, but as long as we mention it in the release notes we should be fine.

/**
* A type annotation, either in the form of a TypeScript type or a JSDoc comment.
*/
class TypeAnnotation extends @type_annotation {

Choose a reason for hiding this comment

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

I suppose we could make this extend Locatable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, although the location of the JSDoc annotations seems to be file://:0:0:0:0. I'll try and see if there's a simple fix for that.

Choose a reason for hiding this comment

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

the location of the JSDoc annotations seems to be file://:0:0:0:0

That doesn't sound intentional. If you can fix it that would be great, but of course it's orthogonal to this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I fixed it. I'll just do it in the same PR.

xiemaisi
xiemaisi previously approved these changes Apr 17, 2019
@asger-semmle asger-semmle added the depends on internal PR This PR should only be merged in sync with an internal Semmle PR label Apr 18, 2019
xiemaisi
xiemaisi previously approved these changes Apr 24, 2019
xiemaisi
xiemaisi previously approved these changes Apr 26, 2019
@asger-semmle asger-semmle removed the WIP This is a work-in-progress, do not merge yet! label Apr 29, 2019
@xiemaisi xiemaisi merged commit 7ca5cc2 into github:master Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

depends on internal PR This PR should only be merged in sync with an internal Semmle PR JS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants