diff --git a/packages/compiler/ambient/scriptc-node-fallback.d.ts b/packages/compiler/ambient/scriptc-node-fallback.d.ts index 4a67ad89b..de3efa0ee 100644 --- a/packages/compiler/ambient/scriptc-node-fallback.d.ts +++ b/packages/compiler/ambient/scriptc-node-fallback.d.ts @@ -770,6 +770,7 @@ interface Request { arrayBuffer(): Promise; bytes(): Promise; } +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; diff --git a/packages/compiler/test/ts7/program-adapter.test.ts b/packages/compiler/test/ts7/program-adapter.test.ts index 4b00c66fd..d7540fe19 100644 --- a/packages/compiler/test/ts7/program-adapter.test.ts +++ b/packages/compiler/test/ts7/program-adapter.test.ts @@ -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-"));