[go: up one dir, main page]

Skip to content
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

Add string literal completions for package.json imports field #57718

Merged
merged 27 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
238651d
Add string literal completions for `package.json` `imports` field
Andarist Mar 11, 2024
2adb14c
format
Andarist Mar 11, 2024
22b6148
Merge remote-tracking branch 'origin/main' into pkg-json-imports-comp…
Andarist Sep 28, 2024
08eaa16
fixed server fixtures
Andarist Sep 28, 2024
083c5b8
drop trailing slash support
Andarist Sep 29, 2024
b48f752
fix support for trailing slash
Andarist Oct 9, 2024
07f6c3c
small tweaks
Andarist Oct 9, 2024
117415a
fixed lint
Andarist Oct 9, 2024
db0d416
pass `moduleSpecifierResolutionHost` everywhere
Andarist Oct 12, 2024
294c7da
`getMatchesWithPrefix` helper
Andarist Oct 12, 2024
0d0b881
add more tests but break some of the existing ones
Andarist Oct 13, 2024
475c0b1
fixed the incorrectly copy-pasted test
Andarist Oct 13, 2024
a0ea1b9
handle `inputDirectories`
Andarist Oct 14, 2024
c00448b
add more tests, some of them still failing
Andarist Oct 14, 2024
e96bd5a
add test with `allowImportingTsExtensions`
Andarist Oct 14, 2024
c36d20a
add extra tests with wildcard in the middle
Andarist Oct 15, 2024
0f4a6f8
add pkg scope test
Andarist Oct 16, 2024
6759383
remove broken path
Andarist Oct 16, 2024
48b2c78
limit imports lookup
Andarist Oct 16, 2024
56a1563
dedupe imports/exports lookup
Andarist Oct 16, 2024
b84468a
handle declarationDir separately
Andarist Oct 16, 2024
a80cdfa
use `ValidationFlags.AllowWildcard`
Andarist Oct 17, 2024
96209a9
allowJs accepts a boolean, not String(boolea), doh
Andarist Oct 17, 2024
17b2aae
split `importsLookup` out of `nodeModulesDirectoryOrImportsLookup` fo…
Andarist Oct 17, 2024
22e4d49
Relax check for `inputExtension`
Andarist Oct 17, 2024
a18104e
swap `matchingSuffixes` to change the priority order for `trimPrefixA…
Andarist Oct 17, 2024
36bed48
fmt
Andarist Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ import {
getParseTreeNode,
getPathComponents,
getPathFromPathComponents,
getRelativePathFromDirectory,
getRelativePathToDirectoryOrUrl,
getResolutionModeOverride,
getRootLength,
Expand Down Expand Up @@ -471,6 +472,7 @@ import {
ResolvedModuleWithFailedLookupLocations,
ResolvedTypeReferenceDirective,
ResolvedTypeReferenceDirectiveWithFailedLookupLocations,
resolvePath,
ReturnStatement,
SatisfiesExpression,
ScriptKind,
Expand Down Expand Up @@ -6288,6 +6290,21 @@ export function getPossibleOriginalInputExtensionForExtension(path: string) {
[Extension.Tsx, Extension.Ts, Extension.Jsx, Extension.Js];
Andarist marked this conversation as resolved.
Show resolved Hide resolved
}

/** @internal */
export function getPossibleOriginalInputPathWithoutChangingExt(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is kinda a reverse of getOutputPathWithoutChangingExt:

function getOutputPathWithoutChangingExt(
inputFileName: string,
ignoreCase: boolean,
outputDir: string | undefined,
getCommonSourceDirectory: () => string,
): string {
return outputDir ?
resolvePath(
outputDir,
getRelativePathFromDirectory(getCommonSourceDirectory(), inputFileName, ignoreCase),
) :
inputFileName;
}

filePath: string,
ignoreCase: boolean,
outputDir: string | undefined,
getCommonSourceDirectory: () => string,
): string {
return outputDir ?
resolvePath(
getCommonSourceDirectory(),
getRelativePathFromDirectory(outputDir, filePath, ignoreCase),
) :
filePath;
}

/**
* Returns 'undefined' if and only if 'options.paths' is undefined.
*
Expand Down
153 changes: 127 additions & 26 deletions src/services/stringCompletions.ts

Large diffs are not rendered by default.

Loading
Loading