-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Offer auto-imports from wildcard exports with AutoImportProvider #54831
Conversation
@typescript-bot user test tsserver |
Heya @andrewbranch, I've started to run the diff-based user code test suite (tsserver) on this PR at 2fc2d7d. You can monitor the build here. Update: The results are in! |
Heya @andrewbranch, I've started to run the perf test suite on this PR at 2fc2d7d. You can monitor the build here. Update: The results are in! |
@andrewbranch Here are the results of running the user test suite comparing Everything looks good! |
@andrewbranch Here they are:
CompilerComparison Report - main..54831
System
Hosts
Scenarios
TSServerComparison Report - main..54831
System
Hosts
Scenarios
StartupComparison Report - main..54831
System
Hosts
Scenarios
Developer Information: |
Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page. Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up. |
The tsserver perf tests didn’t exercise the new code in a meaningful way, apparently (the completion counts were unchanged). I’ll try to do a little manual comparison. |
Discovered an unrelated bug in module specifier generation for wildcard+conditional exports that probably prevented any new completions from being found in the perf tests. Local testing shows that AutoImportProvider initialization time was barely impacted at all even though it finds a good bit more stuff, and then completions response time is pay-for-more-completions as expected. @typescript-bot perf test Unless we see anything weird in the updated perf test, I think this is fine. |
Heya @andrewbranch, I've started to run the perf test suite on this PR at 04c06ee. You can monitor the build here. |
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.
Looks good although my knowledge of module resolution remains somewhat surface-level.
Hey @andrewbranch, something went wrong when publishing results. (You can check the log here). |
@typescript-bot perf test |
Heya @andrewbranch, I've started to run the perf test suite on this PR at 04c06ee. You can monitor the build here. Update: The results are in! |
@andrewbranch Here they are:
CompilerComparison Report - main..54831
System
Hosts
Scenarios
TSServerComparison Report - main..54831
System
Hosts
Scenarios
StartupComparison Report - main..54831
System
Hosts
Scenarios
Developer Information: |
@@ -2620,7 +2622,7 @@ export class AutoImportProviderProject extends Project { | |||
throw new Error("package.json changes should be notified on an AutoImportProvider's host project"); | |||
} | |||
|
|||
override getModuleResolutionHostForAutoImportProvider(): never { | |||
override getHostForAutoImportProvider(): never { |
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.
Should this have been internal to begin with
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.
It’s never been clear to me what parts of TS Server are intended to be public API. It seems like this whole class could be internal.
I'm kind of curious what's meant by this because I personally found The naive implementation of "just return the whole directory listing for the given directory" (and the name implies that should be its only responsibility) ended up pulling too much into the compilation (i.e. literally everything in node_modules, recursively) |
Yeah, I mean it does so much. It’s based on |
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.
I'm not super confident in my ability to review this bit, but it seems okay.
@@ -194,6 +198,15 @@ function formatExtensions(extensions: Extensions) { | |||
return result.join(", "); | |||
} | |||
|
|||
function extensionsToExtensionsArray(extensions: Extensions) { |
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.
Out of curiosity, how often does this happen? Is it worth caching in some way given the key is just a number?
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 number of packages AutoImportProvider will process is capped at 10, so surely not enough times to be make an observable impact.
@@ -2140,7 +2158,7 @@ export function getEntrypointsFromPackageJsonInfo( | |||
function loadEntrypointsFromExportMap( | |||
scope: PackageJsonInfo, | |||
exports: object, | |||
state: ModuleResolutionState, | |||
state: ModuleResolutionState & { host: GetPackageJsonEntrypointsHost }, |
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.
I was going to ask if this would be better served as a parameter rather than tacked onto the state, but it does seem like this was already happening given what's in useCaseSensitiveFileNames
.
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.
This isn’t adding a host
property, it’s narrowing the type of the existing host
property.
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.
Yeah, I was just unsure without trying to find this type (which I should have done!)
ts.sys.readDirectory
is bananas 🍌. I thought this was going to be harder.Fixes #53116