Skip to content

Commit 238651d

Browse files
committed
Add string literal completions for package.json imports field
1 parent 0a97562 commit 238651d

26 files changed

+2610
-26
lines changed

src/compiler/utilities.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ import {
192192
getParseTreeNode,
193193
getPathComponents,
194194
getPathFromPathComponents,
195+
getRelativePathFromDirectory,
195196
getRelativePathToDirectoryOrUrl,
196197
getResolutionModeOverride,
197198
getRootLength,
@@ -471,6 +472,7 @@ import {
471472
ResolvedModuleWithFailedLookupLocations,
472473
ResolvedTypeReferenceDirective,
473474
ResolvedTypeReferenceDirectiveWithFailedLookupLocations,
475+
resolvePath,
474476
ReturnStatement,
475477
SatisfiesExpression,
476478
ScriptKind,
@@ -6288,6 +6290,21 @@ export function getPossibleOriginalInputExtensionForExtension(path: string) {
62886290
[Extension.Tsx, Extension.Ts, Extension.Jsx, Extension.Js];
62896291
}
62906292

6293+
/** @internal */
6294+
export function getPossibleOriginalInputPathWithoutChangingExt(
6295+
filePath: string,
6296+
ignoreCase: boolean,
6297+
outputDir: string | undefined,
6298+
getCommonSourceDirectory: () => string,
6299+
): string {
6300+
return outputDir ?
6301+
resolvePath(
6302+
getCommonSourceDirectory(),
6303+
getRelativePathFromDirectory(outputDir, filePath, ignoreCase),
6304+
) :
6305+
filePath;
6306+
}
6307+
62916308
/**
62926309
* Returns 'undefined' if and only if 'options.paths' is undefined.
62936310
*

src/services/stringCompletions.ts

Lines changed: 127 additions & 26 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)