Skip to content

Conversation

@erik-krogh
Copy link
Contributor

@erik-krogh erik-krogh commented Aug 11, 2020

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:

  • ensure all new features work
  • change note
  • better NamedTupleElement support.
  • update semmlecode.javascript.dbscheme sha internally
  • dbscheme upgrade script
  • update upgrade script
  • trap cache update
  • Do an evaluation on typescript-full
  • Wait for stable release of TypeScript 4
  • download stable TypeScript 4 for offline mirror

@erik-krogh erik-krogh added the JS label Aug 11, 2020
@erik-krogh
Copy link
Contributor Author

@asgerf can I get an early review?

@asgerf asgerf self-requested a review August 12, 2020 12:34
Copy link
Contributor

@asgerf asgerf left a 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());
Copy link
Contributor

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 |
Copy link
Contributor

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?

Copy link
Contributor Author

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);
Copy link
Contributor

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.

@erik-krogh
Copy link
Contributor Author

All new features of TypeScript 4 are supported.

The awaited type was initially merged into TypeScript, but it was later reverted.

.map(n -> n.getAsJsonObject().get("escapedText"))
.map(n -> n.getAsString())
.collect(Collectors.toList());
.collect(Collectors.toList())
Copy link
Contributor

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.

Copy link
Contributor Author

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, ...
Copy link
Contributor

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.

@adityasharad adityasharad changed the base branch from master to main August 14, 2020 18:33
@erik-krogh
Copy link
Contributor Author

An evaluation on typescript-full looks fine.

Except for Kibana that runs out of memory on master.

@asgerf
Copy link
Contributor

asgerf commented Aug 21, 2020

Looking good! 👍 I've merged the internal PR and restarted the test.

@erik-krogh
Copy link
Contributor Author

And the tests are green 🎉

@erik-krogh erik-krogh marked this pull request as ready for review August 21, 2020 12:30
@erik-krogh erik-krogh requested a review from a team as a code owner August 21, 2020 12:30
@erik-krogh erik-krogh added the depends on internal PR This PR should only be merged in sync with an internal Semmle PR label Aug 21, 2020
Copy link
Contributor

@asgerf asgerf left a 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. 💪

@asgerf asgerf merged commit 813d147 into github:main Aug 28, 2020
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