Skip to content

Conversation

kaeluka
Copy link

@kaeluka kaeluka commented May 20, 2022

Erik here:

A plain update to TypeScript 4.7 without surprises.

There is not much special happening, but TypeScript now supports .mts and .cts files, so we had to add those to the extractor.

Tests have been added that we can handle all the features mentioned in the change-notes.

I can't test it locally, but the tests passed on the release candidate, so I highly expect them to pass on this stable release.
The tests will fail here until the internal PR has been merged.

@kaeluka kaeluka changed the title Extractor update typescript 4.7 JS: Extractor update typescript 4.7 May 20, 2022
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.

I don't see a test/implementation of moduleSuffixes.
It can wait until after this PR has been merged, but we should consider it.
https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-rc/#resolution-customization-with-modulesuffixes

It probably requires some changes in NodeModuleResolutionImpl.qll around the tryExtensions predicate.


Otherwise LGTM, with two small comments from a quick look.

Stephan Brandauer and others added 3 commits May 20, 2022 14:33
@kaeluka
Copy link
Author

kaeluka commented May 20, 2022

I've now added a test for the moduleSuffixes feature as well!

@erik-krogh
Copy link
Contributor

erik-krogh commented May 20, 2022

I've now added a test for the moduleSuffixes feature as well!

You've tested that TypeScript can figure out the types, but not that our own module resolution can figure out the imports.
(See NodeModuleResolutionImpl.qll).
It can wait until after this PR has been merged.

@kaeluka
Copy link
Author

kaeluka commented May 20, 2022

Yes, that's what I did :-) i know there's still work left after merging 👍

@erik-krogh erik-krogh changed the title JS: Extractor update typescript 4.7 JS: Update the extractor to use TypeScript 4.7 May 24, 2022
@erik-krogh
Copy link
Contributor

erik-krogh commented May 24, 2022

I've bumped the version to the stable release that just happened.
It would be nice to get someone else to review it.

The tests will still fail until the internal PR has been merged (see backref above).

@erik-krogh erik-krogh marked this pull request as ready for review May 24, 2022 21:04
@erik-krogh erik-krogh requested a review from a team as a code owner May 24, 2022 21:04
///////////

const ErrorMap = Map<string, Error>;
Copy link
Contributor

Choose a reason for hiding this comment

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

What AST do we extract for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

The Map<string,Error> is an ExpressionWithTypeArguments from TypeScript.qll.

But we did not show that in the printAst output, so I fixed that.


type FirstString<T> =
T extends [infer S extends string, ...unknown[]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we extract the extends string part?

Usually we've tried to extract enough of the AST to prevent spurious unused variable/import alerts. Since the extends string part could instead contain a reference to an imported name, we'd want to extract it.

The unused variable alert isn't that important anymore, but I still think we should try to maintain it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes we extract it, and I've added a test that it works with our unused variable query.

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.

Thanks for addressing my questions @erik-krogh!

Everything LGTM, but could you please run an evaluation before merging?

@erik-krogh
Copy link
Contributor

Thanks for addressing my questions @erik-krogh!

Everything LGTM, but could you please run an evaluation before merging?

Evaluation was uneventful.
We extract one more LOC in Babel. I suppose that comes from a TS test-case.

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.

Great! LGTM

@erik-krogh erik-krogh merged commit c7a8008 into github:main May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants