Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
93a3037
Reject empty createSourceFile names (PORT TO MAIN, TYPED PATHS, STRAD…
jakebailey Sep 17, 2026
ff7635b
Fix inherited path presentation loss (PORT TO MAIN, TYPED PATHS, STRA…
jakebailey Sep 4, 2026
ef83bc4
Test auto-import package directory realpaths (PORT TO MAIN, TYPED PAT…
jakebailey Sep 2, 2026
7ed158b
Fix auto-import package directory realpaths (PORT TO MAIN, TYPED PATH…
jakebailey Sep 2, 2026
08f43bc
Test node_modules package path kinds (PORT TO MAIN, TYPED PATHS, STRA…
jakebailey Sep 2, 2026
4556b17
Type node_modules package path kinds (PORT TO MAIN, TYPED PATHS, STRA…
jakebailey Sep 2, 2026
1fe75bb
Test nested package.json specifiers (PORT TO MAIN, TYPED PATHS, STRAD…
jakebailey Sep 2, 2026
382a9b6
Fix nested package.json specifiers (PORT TO MAIN, TYPED PATHS, STRADA…
jakebailey Sep 2, 2026
405e113
Test nested triple-slash redirects (PORT TO MAIN, TYPED PATHS, STRADA…
jakebailey Sep 2, 2026
f058ebd
Fix nested triple-slash redirects (PORT TO MAIN, TYPED PATHS, STRADA …
jakebailey Sep 2, 2026
14e6599
Fix project-relative API import edits (PORT TO MAIN, TYPED PATHS, STR…
jakebailey Sep 2, 2026
fc88982
Fix project-relative API source cache (PORT TO MAIN, TYPED PATHS, NAT…
jakebailey Sep 2, 2026
8c8f73a
Recognize local file URL roots case-insensitively (PORT TO MAIN, REVI…
jakebailey Sep 4, 2026
f11c207
Decode imported source maps safely (PORT TO MAIN, REVIEW, STRADA BUG)
jakebailey Sep 4, 2026
936a398
Preserve structured non-file URI identity (PORT TO MAIN, REVIEW, STRA…
jakebailey Sep 8, 2026
9ca67bd
Validate completion item file names (PORT TO MAIN, REVIEW, NATIVE ONLY)
jakebailey Sep 8, 2026
9e21605
Keep failed API updates transactional (PORT TO MAIN, REVIEW, NATIVE O…
jakebailey Sep 4, 2026
5a30645
Release the final session snapshot (PORT TO MAIN, REVIEW, NATIVE ONLY)
jakebailey Sep 4, 2026
8e388fb
Match content mapper manifests canonically (PORT TO MAIN, REVIEW, NAT…
jakebailey Sep 4, 2026
46b7f39
Harden virtual filesystem lookups (PORT TO MAIN, REVIEW, NATIVE API)
jakebailey Sep 16, 2026
dcc49e7
Introduce typed path invariants throughout tsc (TYPED PATHS)
jakebailey Sep 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions packages/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
"@typescript/source": "./src/api/fs.ts",
"default": "./dist/api/fs.js"
},
"./unstable/path": {
"@typescript/source": "./src/api/typedPaths.ts",
"default": "./dist/api/typedPaths.js"
},
"./unstable/proto": {
"@typescript/source": "./src/api/proto.ts",
"default": "./dist/api/proto.js"
Expand Down
125 changes: 79 additions & 46 deletions packages/typescript/src/api/async/api.ts

Large diffs are not rendered by default.

68 changes: 43 additions & 25 deletions packages/typescript/src/api/async/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import {
} from "#vscode-jsonrpc/node";
import type { ChildProcess } from "node:child_process";
import type { Socket } from "node:net";
import type {
RootedDirectoryPath,
RootedFilePath,
RootedPath,
} from "../../ast/index.ts";
import {
type FileSystem,
fsCallbackNames,
Expand Down Expand Up @@ -141,32 +146,45 @@ export class Client {
private registerFSCallbacks(connection: MessageConnection, fs: FileSystem | undefined): void {
if (!fs) return;
for (const name of fsCallbackNames) {
if (name === "writeFile") {
if (!fs.writeFile) continue;
const callback = fs.writeFile;

const requestType = new RequestType<{ path: string; data: string; }, unknown, void>(name);
connection.onRequest(requestType, (arg: { path: string; data: string; }) => {
callback(arg.path, arg.data);
return null;
});

continue;
}

const callback = fs[name];
if (callback) {
const requestType = new RequestType<unknown, unknown, void>(name);
connection.onRequest(requestType, (arg: unknown) => {
const result = callback(arg as any);
if (name === "readFile") {
// readFile has 3 returns: string (content), null (not found), undefined (fall back).
// JSON-RPC can't distinguish null from undefined, so wrap in object.
if (result === undefined) return null;
return { content: result };
switch (name) {
case "readFile":
if (fs.readFile) {
connection.onRequest(new RequestType<RootedFilePath, unknown, void>(name), fileName => {
const result = fs.readFile!(fileName);
// readFile has 3 returns: string (content), null (not found), undefined (fall back).
// JSON-RPC can't distinguish null from undefined, so wrap in object.
return result === undefined ? null : { content: result };
});
}
break;
case "fileExists":
if (fs.fileExists) {
connection.onRequest(new RequestType<RootedFilePath, unknown, void>(name), fileName => fs.fileExists!(fileName) ?? null);
}
break;
case "directoryExists":
if (fs.directoryExists) {
connection.onRequest(new RequestType<RootedDirectoryPath, unknown, void>(name), directoryName => fs.directoryExists!(directoryName) ?? null);
}
break;
case "getAccessibleEntries":
if (fs.getAccessibleEntries) {
connection.onRequest(new RequestType<RootedDirectoryPath, unknown, void>(name), directoryName => fs.getAccessibleEntries!(directoryName) ?? null);
}
break;
case "realpath":
if (fs.realpath) {
connection.onRequest(new RequestType<RootedPath, unknown, void>(name), path => fs.realpath!(path) ?? null);
}
break;
case "writeFile":
if (fs.writeFile) {
connection.onRequest(new RequestType<{ path: RootedFilePath; data: string; }, unknown, void>(name), arg => {
fs.writeFile!(arg.path, arg.data);
return null;
});
}
return result ?? null;
});
break;
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions packages/typescript/src/api/async/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import type {
NamedTupleMember,
ParameterDeclaration,
} from "../../ast/ast.ts";
import type {
RootedDirectoryPath,
RootedFilePath,
} from "../../ast/index.ts";
import type {
Diagnostic,
RequestFileSystem,
Expand Down Expand Up @@ -410,28 +414,28 @@ export interface CompletionInfo {
}

export interface FormatDiagnosticsHost {
getCurrentDirectory(): string;
getCurrentDirectory(): RootedDirectoryPath;
getCanonicalFileName(fileName: string): string;
getNewLine(): string;
}

export interface EmitOutputFile {
readonly text: string;
readonly sourceFileName?: string | undefined;
readonly sourceFileName?: RootedFilePath | undefined;
}

export interface EmitResult {
readonly emitSkipped: boolean;
readonly diagnostics: readonly Diagnostic[];
readonly emittedFiles: readonly string[];
readonly emittedFiles: readonly RootedFilePath[];
/** Emitted files captured as a filesystem layer suitable for {@link Snapshot.update}. */
readonly fileSystem?: RequestFileSystem | undefined;
}

export interface EmitOutput {
readonly emitSkipped: boolean;
readonly diagnostics: readonly Diagnostic[];
readonly outputFiles: ReadonlyMap<string, EmitOutputFile>;
readonly outputFiles: ReadonlyMap<RootedFilePath, EmitOutputFile>;
}

export interface ImportSymbolAction {
Expand Down
8 changes: 6 additions & 2 deletions packages/typescript/src/api/diagnosticFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import type {
RootedDirectoryPath,
RootedFilePath,
} from "../ast/index.ts";
import { convertToRelativePath } from "./path.ts";
import type { DiagnosticResponse as Diagnostic } from "./proto.generated.ts";

export interface FormatDiagnosticsHost {
getCurrentDirectory(): string;
getCurrentDirectory(): RootedDirectoryPath;
getCanonicalFileName(fileName: string): string;
getNewLine(): string;
}
Expand Down Expand Up @@ -70,7 +74,7 @@ function flattenDiagnosticMessage(diagnostic: Diagnostic, newLine: string, inden
return result;
}

function relativeFileName(fileName: string, host: FormatDiagnosticsHost): string {
function relativeFileName(fileName: RootedFilePath, host: FormatDiagnosticsHost): string {
return convertToRelativePath(
fileName,
host.getCurrentDirectory(),
Expand Down
Loading
Loading