fix(compiler): declare RequestInfo in fallback ambient

- Add the Node-compatible RequestInfo alias without widening supported fetch inputs.
- Cover RequestInfo resolution at the shared preflight boundary.

Fixes #369

Co-authored-by: Hagege Ruben <20857346+HagegeR@users.noreply.github.com>
This commit is contained in:
Chris Tate
2026-09-22 11:51:24 -05:00
co-authored by Hagege Ruben
parent 8a12d34a1d
commit 8ff23bfaf3
2 changed files with 22 additions and 1 deletions
+2 -1
View File
@@ -770,6 +770,7 @@ interface Request {
arrayBuffer(): Promise<ArrayBuffer>;
bytes(): Promise<Uint8Array>;
}
type RequestInfo = string | URL | Request;
interface RequestInit {
method?: string;
headers?:
@@ -782,7 +783,7 @@ interface RequestInit {
signal?: AbortSignal;
}
declare var Request: {
new (input: string | URL | Request, init?: RequestInit): Request;
new (input: RequestInfo, init?: RequestInit): Request;
readonly prototype: Request;
};
declare function fetch(input: string | URL, init?: RequestInit): Promise<Response>;
@@ -68,6 +68,26 @@ test("retains source-file BOM stripping", () => {
}
});
test("fallback ambient resolves RequestInfo during preflight", () => {
const tempRoot = process.platform === "win32" ? tmpdir() : "/tmp";
const dir = mkdtempSync(join(tempRoot, "scriptc-request-info-"));
const entry = join(dir, "entry.ts");
writeFileSync(entry, [
'const target: RequestInfo = "https://example.invalid/";',
"console.log(typeof target);",
].join("\n"));
const load = loadProgram(entry);
try {
const diagnostics = checkPreflight(load);
expect(diagnostics, diagnostics.map((diag) => `${diag.code}: ${diag.message}`).join("\n"))
.toEqual([]);
} finally {
load.dispose();
rmSync(dir, { recursive: true, force: true });
}
});
test("preflight batches symbols in deferred TDZ-analysis roots", () => {
const tempRoot = process.platform === "win32" ? tmpdir() : "/tmp";
const dir = mkdtempSync(join(tempRoot, "scriptc-preflight-batch-"));