Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
71d1d9c
[api] Add module resolution APIs
andrewbranch Sep 15, 2026
89bdab8
Format rebased module resolution changes
andrewbranch Sep 15, 2026
c49318e
Support module resolution overrides and programless resolveModuleName
andrewbranch Sep 15, 2026
cf4a7b7
Add callback as a way of overriding too
andrewbranch Sep 15, 2026
6f1803d
Merge remote-tracking branch 'origin/main' into api-module-resolution
andrewbranch Sep 17, 2026
5cfe713
Test module resolution state updates
andrewbranch Sep 17, 2026
67b47d4
Move module resolution state tests to API client
andrewbranch Sep 18, 2026
be9c56e
Merge remote-tracking branch 'upstream/main' into api-module-resolution
andrewbranch Sep 18, 2026
314fd68
Format
andrewbranch Sep 18, 2026
f91176d
Fix snapshot params, add test for lack of resolvedUsingTsExtension
andrewbranch Sep 18, 2026
404b3ba
Decouple module resolver behavior/data
andrewbranch Sep 18, 2026
9969e79
Allow sync client reentrant calls
andrewbranch Sep 18, 2026
a3883d9
Move resolutionMode to top-level parameter
andrewbranch Sep 18, 2026
f8fd191
Refine
andrewbranch Sep 18, 2026
cdae85f
Merge branch 'main' into api-module-resolution
andrewbranch Sep 18, 2026
6c4f710
Fix multiple things
andrewbranch Sep 18, 2026
65ca1dd
Remove InProgressSnapshot class
andrewbranch Sep 19, 2026
4f09ae9
Fix EOP types
andrewbranch Sep 19, 2026
f299c1f
Generate
andrewbranch Sep 19, 2026
5b7335d
Return resolveModuleName callback errors as API errors
andrewbranch Sep 19, 2026
ef0ee30
Make static resolver accessible via public Go API
andrewbranch Sep 21, 2026
f16e60f
Further renaming and cleaning up
andrewbranch Sep 22, 2026
18c045d
Merge branch 'main' into api-module-resolution
andrewbranch Sep 22, 2026
13e887b
Delete atrocity
andrewbranch Sep 23, 2026
f42df8d
Merge branch 'main' into api-module-resolution
andrewbranch Sep 23, 2026
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
205 changes: 181 additions & 24 deletions packages/typescript/src/api/async/api.ts

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions packages/typescript/src/api/async/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ export class Client {
return result;
}

registerCallback(name: string, callback: (params: unknown) => unknown | Promise<unknown>): () => void {
if (!this.connection) {
throw new Error("Connection not established");
}
const disposable = this.connection.onRequest(new RequestType<unknown, unknown, void>(name), callback);
return () => disposable.dispose();
}

private async doBatch(): Promise<void> {
this.nextBatch = undefined;
if (!this.batchedRequests.length) return;
Expand Down
55 changes: 55 additions & 0 deletions packages/typescript/src/api/proto.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export interface APIMethodInfo {
createSnapshot: APIMethod<CreateSnapshotParams, CreateSnapshotResponse>;
updateSnapshot: APIMethod<UpdateSnapshotParams, CreateSnapshotResponse>;
getCurrentLanguageServerSnapshot: APIMethod<GetCurrentLanguageServerSnapshotParams, CreateSnapshotResponse>;
createModuleResolver: APIMethod<CreateModuleResolverParams, number>;
releaseModuleResolver: APIMethod<ReleaseModuleResolverParams, unknown>;
resolveModuleName: APIMethod<ResolveModuleNameParams, ResolveModuleNameResult>;
parseCommandLine: APIMethod<ParseCommandLineParams, ConfigFileResponse>;
readConfigFile: APIMethod<ReadConfigFileParams, ReadConfigFileResponse>;
parseJsonConfigFileContent: APIMethod<ParseJsonConfigFileContentParams, ConfigFileResponse>;
Expand Down Expand Up @@ -185,6 +188,8 @@ export interface APIMethodInfo {

export type DocumentIdentifier = string | { uri: string; };

export type ResolutionMode = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.ESNext;

export type EnsurePrograms = true | readonly ProjectId[];

export type InferredProjectId = string & { __inferredProjectIdBrand: any; };
Expand Down Expand Up @@ -253,6 +258,31 @@ export interface GetCurrentLanguageServerSnapshotParams {
changes?: LanguageServerSnapshotChanges | undefined;
}

export interface CreateModuleResolverParams {
compilerOptions: CompilerOptions;
moduleResolutions?: ModuleResolutionSpec | undefined;
resolveModuleNameCallback?: string | undefined;
}

export interface ReleaseModuleResolverParams {
resolver: number;
}

export interface ResolveModuleNameParams {
snapshot?: number | undefined;
inProgressSnapshot?: number | undefined;
resolver: number;
moduleName: string;
containingDirectory: DocumentIdentifier;
resolutionMode?: ResolutionMode | undefined;
}

export interface ResolveModuleNameResult {
resolvedModule?: ResolvedModule | undefined;
/** Trace is provided when compilerOptions.traceResolution is true. */
trace?: string[] | undefined;
}

export interface ParseCommandLineParams {
commandLine: readonly string[] | null;
}
Expand Down Expand Up @@ -1008,6 +1038,7 @@ export interface ProfileResult {
export interface BatchRequest {
method:
| "batchRequests"
| "createModuleResolver"
| "createSnapshot"
| "createSourceFile"
| "createSourceFileFromFile"
Expand Down Expand Up @@ -1156,6 +1187,8 @@ export interface BatchRequest {
| "printNode"
| "readConfigFile"
| "release"
| "releaseModuleResolver"
| "resolveModuleName"
| "resolveName"
| "saveHeapProfile"
| "signatureToSignatureDeclaration"
Expand All @@ -1174,6 +1207,7 @@ export interface BatchRequest {
export interface BatchResponse {
method:
| "batchRequests"
| "createModuleResolver"
| "createSnapshot"
| "createSourceFile"
| "createSourceFileFromFile"
Expand Down Expand Up @@ -1322,6 +1356,8 @@ export interface BatchResponse {
| "printNode"
| "readConfigFile"
| "release"
| "releaseModuleResolver"
| "resolveModuleName"
| "resolveName"
| "saveHeapProfile"
| "signatureToSignatureDeclaration"
Expand Down Expand Up @@ -1550,6 +1586,11 @@ export interface CompilerOptions {
configFilePath?: string | undefined;
}

export interface ModuleResolutionSpec {
fallback: "resolve" | "unresolved";
entries: ModuleResolutionEntry[];
}

export interface ProjectReference {
/** Path is a normalized path on disk. */
path: string;
Expand Down Expand Up @@ -1669,6 +1710,13 @@ export interface PluginImport {
name: string;
}

export interface ModuleResolutionEntry {
moduleName: string;
containingDirectory?: DocumentIdentifier | undefined;
resolutionMode?: ResolutionMode | undefined;
result: StaticModuleResolution;
}

/** CompletionEntryLabelDetailsResponse holds additional label display text for a completion entry. */
export interface CompletionEntryLabelDetailsResponse {
detail?: string | undefined;
Expand All @@ -1678,4 +1726,11 @@ export interface CompletionEntryLabelDetailsResponse {
export interface CreateProgramOptions {
projectReferences?: ProjectReference[] | undefined;
configFileParsingDiagnostics?: DiagnosticResponse[] | undefined;
moduleResolver?: number | undefined;
}

export interface StaticModuleResolution {
resolvedFileName?: DocumentIdentifier | undefined;
originalPath?: DocumentIdentifier | undefined;
packageId?: PackageId | undefined;
}
Loading
Loading