-
Notifications
You must be signed in to change notification settings - Fork 1.9k
JS: Add support for TypeScript 4 #4043
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
Conversation
|
@asgerf can I get an early review? |
asgerf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments so far, also check the backlinked internal issue.
| .map(n -> n.getAsJsonObject().get("name")) | ||
| .map(n -> n.getAsJsonObject().get("escapedText")) | ||
| .map(n -> n.getAsString()) | ||
| .collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should extract an AST node for the identifier instead of just the name.
(Also, we have getIdentifierText instead of reading "escapedText" manually, but this will likely not matter if extracting the identifier)
| | tst.ts:26:15:26:24 | () => void | () => void | | ||
| | tst.ts:27:5:27:17 | undefinedType | undefined | | ||
| | tst.ts:28:5:28:12 | nullType | null | | ||
| | tst.ts:28:22:28:25 | null | null | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh? The null expression no longer has a type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently so ¯\_(ツ)_/¯ . I have no idea why.
We could manually add it to getType(), but that just seems hacky.
| binOpKinds.put("??", 107); | ||
| binOpKinds.put("&&=", 116); | ||
| binOpKinds.put("||=", 117); | ||
| binOpKinds.put("??=", 118); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to update CFGExtractor as the control-flow graph for these operators is not like other binary operators; the right-hand side is only conditionally evaluated.
|
All new features of TypeScript 4 are supported. The |
javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java
Outdated
Show resolved
Hide resolved
| .map(n -> n.getAsJsonObject().get("escapedText")) | ||
| .map(n -> n.getAsString()) | ||
| .collect(Collectors.toList()); | ||
| .collect(Collectors.toList()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indices won't match up if some tuple elements are named and others aren't. I think we'll just have to use an array with holes even though it's ugly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indices won't match up if some tuple elements are named and others aren't.
That is a type-error in TypeScript. But yeah, its a good idea to support it anyway.
| * Gets the name of the `n`th tuple member, starting at 0. | ||
| * Only has a result if the tuple members are named. | ||
| * | ||
| * Type element names are at indices -1, -2, -3, ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment about indices should be in a regular non-doc comment.
Co-authored-by: Asger F <asgerf@github.com>
|
An evaluation on typescript-full looks fine. Except for |
|
Looking good! 👍 I've merged the internal PR and restarted the test. |
|
And the tests are green 🎉 |
asgerf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! Let's do this. 💪
In progress PR for updating to TypeScript 4.0.
There wasn't much to change, but it still required a few additions.
All test pass on my machine (where I got an offline copy of
typescript-4.0.1-rc.tgz).TODO:
NamedTupleElementsupport.trap cache update