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
9dc3242
Reject empty createSourceFile names (PORT TO MAIN, TYPED PATHS, STRAD…
jakebailey Sep 17, 2026
d639aec
Fix inherited path presentation loss (PORT TO MAIN, TYPED PATHS, STRA…
jakebailey Sep 4, 2026
ae34681
Test auto-import package directory realpaths (PORT TO MAIN, TYPED PAT…
jakebailey Sep 2, 2026
83784e2
Fix auto-import package directory realpaths (PORT TO MAIN, TYPED PATH…
jakebailey Sep 2, 2026
e993355
Test node_modules package path kinds (PORT TO MAIN, TYPED PATHS, STRA…
jakebailey Sep 2, 2026
5bdf343
Type node_modules package path kinds (PORT TO MAIN, TYPED PATHS, STRA…
jakebailey Sep 2, 2026
7927620
Test nested package.json specifiers (PORT TO MAIN, TYPED PATHS, STRAD…
jakebailey Sep 2, 2026
e250fdf
Fix nested package.json specifiers (PORT TO MAIN, TYPED PATHS, STRADA…
jakebailey Sep 2, 2026
6baa960
Test nested triple-slash redirects (PORT TO MAIN, TYPED PATHS, STRADA…
jakebailey Sep 2, 2026
46740f1
Fix nested triple-slash redirects (PORT TO MAIN, TYPED PATHS, STRADA …
jakebailey Sep 2, 2026
3fa0bb1
Fix project-relative API import edits (PORT TO MAIN, TYPED PATHS, STR…
jakebailey Sep 2, 2026
7312433
Fix project-relative API source cache (PORT TO MAIN, TYPED PATHS, NAT…
jakebailey Sep 2, 2026
49b34e0
Recognize local file URL roots case-insensitively (PORT TO MAIN, REVI…
jakebailey Sep 4, 2026
dd85223
Decode imported source maps safely (PORT TO MAIN, REVIEW, STRADA BUG)
jakebailey Sep 4, 2026
dc09cf8
Preserve structured non-file URI identity (PORT TO MAIN, REVIEW, STRA…
jakebailey Sep 8, 2026
5c4198c
Validate completion item file names (PORT TO MAIN, REVIEW, NATIVE ONLY)
jakebailey Sep 8, 2026
e9785ef
Keep failed API updates transactional (PORT TO MAIN, REVIEW, NATIVE O…
jakebailey Sep 4, 2026
28b02a0
Release the final session snapshot (PORT TO MAIN, REVIEW, NATIVE ONLY)
jakebailey Sep 4, 2026
2134c0a
Match content mapper manifests canonically (PORT TO MAIN, REVIEW, NAT…
jakebailey Sep 4, 2026
8bf55f8
Harden virtual filesystem lookups (PORT TO MAIN, REVIEW, NATIVE API)
jakebailey Sep 16, 2026
4d524db
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
  •  
  •  
  •  
1 change: 1 addition & 0 deletions Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ const enumDefs = [
{ name: "NewLineKind", goPrefix: "NewLineKind", goFile: "tsc/internal/core/compileroptions.go", outDir: "packages/typescript/src/enums" },
{ name: "JsxEmit", goPrefix: "JsxEmit", goFile: "tsc/internal/core/compileroptions.go", outDir: "packages/typescript/src/enums" },
{ name: "ScriptKind", goPrefix: "ScriptKind", goFile: "tsc/internal/core/scriptkind.go", outDir: "packages/typescript/src/enums" },
{ name: "CaseSensitivity", goPrefix: "Case", goFile: "tsc/internal/tspath/path.go", outDir: "packages/typescript/src/enums" },
{ name: "TokenFlags", goPrefix: "TokenFlags", goFile: "tsc/internal/ast/tokenflags.go", outDir: "packages/typescript/src/enums" },
{ name: "DiagnosticDirectivePolicy", goPrefix: "MappedDiagnosticDirectivePolicy", goFile: "tsc/internal/ast/ast.go", outDir: "packages/typescript/src/enums" },
{ name: "SpanMapKind", goPrefix: "Kind", goFile: "tsc/internal/spanmap/spanmap.go", outDir: "packages/typescript/src/enums" },
Expand Down
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 @@ -396,28 +400,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