-
Notifications
You must be signed in to change notification settings - Fork 12.9k
At types prefix and import suffix #15545
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
Changes from 3 commits
f20a330
5444f3c
f2e5fa5
5ce32cc
69e7841
d38ee1e
5eff8c2
0b68b93
7282b9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -501,6 +501,14 @@ namespace ts.codefix { | |
relativeFileName = getRelativePath(moduleFileName, sourceDirectory); | ||
} | ||
|
||
if (startsWith(relativeFileName, "@types/")) { | ||
relativeFileName = relativeFileName.substr(/*"@types".length*/ 7); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be "@types/" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed. |
||
if (relativeFileName.indexOf("__") !== -1) { | ||
// Double underscores are used in DefinitelyTyped to delimit scoped packages. | ||
relativeFileName = "@" + relativeFileName.replace("__", "/"); | ||
} | ||
} | ||
|
||
relativeFileName = removeFileExtension(relativeFileName); | ||
if (endsWith(relativeFileName, "/index")) { | ||
relativeFileName = getDirectoryPath(relativeFileName); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
//// [|f1/*0*/();|] | ||
|
||
// @Filename: node_modules/@types/myLib/index.d.ts | ||
//// export function f1() {} | ||
//// export var v1 = 5; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem to be used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It exercises whether we look through the set of exported members correctly. |
||
|
||
verify.importFixAtPosition([ | ||
`import { f1 } from "myLib"; | ||
|
||
f1();` | ||
]); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
//// [|f1/*0*/();|] | ||
|
||
// @Filename: node_modules/@types/myLib__scoped/index.d.ts | ||
//// export function f1() {} | ||
//// export var v1 = 5; | ||
|
||
verify.importFixAtPosition([ | ||
`import { f1 } from "@myLib/scoped"; | ||
|
||
f1();` | ||
]); |
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 would be nice to have this code next to
mangleScopedPackage
inmoduleNameResolver.ts
. Maybe call itgetPackageNameFromAtTypesDirectory
.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.
changed.