-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Update symlink cache from AutoImportProvider resolution even if host project already contains the file via its realpath #46830
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
Merged
andrewbranch
merged 1 commit into
microsoft:main
from
andrewbranch:bug/auto-import-provider-symlink
Nov 17, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/// <reference path="../fourslash.ts" /> | ||
|
||
// @Filename: /tsconfig.json | ||
//// { "compilerOptions": { "module": "commonjs" } } | ||
|
||
// @Filename: /package.json | ||
//// { "dependencies": { "mylib": "file:packages/mylib" } } | ||
|
||
// @Filename: /packages/mylib/package.json | ||
//// { "name": "mylib", "version": "1.0.0", "main": "index.js", "types": "index" } | ||
|
||
// @Filename: /packages/mylib/index.ts | ||
//// export * from "./mySubDir"; | ||
|
||
// @Filename: /packages/mylib/mySubDir/index.ts | ||
//// export * from "./myClass"; | ||
//// export * from "./myClass2"; | ||
|
||
// @Filename: /packages/mylib/mySubDir/myClass.ts | ||
//// export class MyClass {} | ||
|
||
// @Filename: /packages/mylib/mySubDir/myClass2.ts | ||
//// export class MyClass2 {} | ||
|
||
// @link: /packages/mylib -> /node_modules/mylib | ||
|
||
// @Filename: /src/index.ts | ||
//// | ||
//// const a = new MyClass/*1*/(); | ||
//// const b = new MyClass2/*2*/(); | ||
|
||
goTo.marker("1"); | ||
format.setOption("newLineCharacter", "\n"); | ||
|
||
verify.completions({ | ||
marker: "1", | ||
includes: [{ | ||
name: "MyClass", | ||
source: "mylib", | ||
sourceDisplay: "mylib", | ||
hasAction: true, | ||
sortText: completion.SortText.AutoImportSuggestions, | ||
}], | ||
preferences: { | ||
includeCompletionsForModuleExports: true, | ||
includeInsertTextCompletions: true, | ||
allowIncompleteCompletions: true, | ||
} | ||
}); | ||
|
||
verify.applyCodeActionFromCompletion("1", { | ||
name: "MyClass", | ||
source: "mylib", | ||
description: `Import 'MyClass' from module "mylib"`, | ||
data: { | ||
exportName: "MyClass", | ||
fileName: "/packages/mylib/index.ts", | ||
}, | ||
preferences: { | ||
includeCompletionsForModuleExports: true, | ||
includeCompletionsWithInsertText: true, | ||
allowIncompleteCompletions: true, | ||
}, | ||
newFileContent: `import { MyClass } from "mylib"; | ||
|
||
const a = new MyClass(); | ||
const b = new MyClass2();`, | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 other part of the bug is this—for this test to work, this package.json needs
"types": "index"
exactly—leaving it off or specifying any file extension breaks the resolution attempted by the AutoImportProviderProject. My attempt to leverageresolveTypeReferenceDirective
for this has hit its limit; there probably needs to be a much more permissive module resolution function written specifically for this. I’ll follow up with a separate PR for that.