Files
scriptc/tests/fixtures/fetch/spread-wrapper/main.mts
Chris Tate 39db8c0a99 feat(compiler): make lowering contexts natively compilable
- Run production scope and closure capture logic with native TypeScript 7 symbols.
- Give lowering caches explicit pass ownership and stable symbol identities.
- Support reference collection arrays and optional Set seeds on both native backends.
2026-09-28 19:48:46 -05:00

22 lines
829 B
TypeScript

/// <reference types="node" />
const baseUrl = process.argv[2]!;
const base: { init: RequestInit } = { init: { cache: "no-store" } };
const options: { init: RequestInit } = { ...base, init: { method: "GET" } };
const response = await fetch(`${baseUrl}/text`, options.init);
const text: string = await response.text();
console.log(`${response.status}`, text);
let order = "";
function source(): { init: RequestInit } {
order += "source";
return base;
}
function replacement(): RequestInit {
order += ",replacement";
return { method: "POST", body: "spread body" };
}
const copied: { init: RequestInit } = { ...source(), init: replacement() };
const posted = await fetch(`${baseUrl}/post-echo`, copied.init);
const body = await posted.json() as { method: string; body: string };
console.log(order, body.method, body.body);