From 97d6ebac6a17327ae28ebf0ecef2a28dd9152b61 Mon Sep 17 00:00:00 2001 From: Chris Tate Date: Tue, 20 Oct 2026 20:22:18 -0500 Subject: [PATCH] Revert "Check the optional-record path test's cast at the cast (#1592)" --- tests/harness/dyncheck.test.ts | 37 ++++++---------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/tests/harness/dyncheck.test.ts b/tests/harness/dyncheck.test.ts index 93709f7f88..6a2d4dc618 100644 --- a/tests/harness/dyncheck.test.ts +++ b/tests/harness/dyncheck.test.ts @@ -309,11 +309,10 @@ console.log("unreachable", c.host); // `Partial` makes every member an `X | undefined` union. A present // object that fails X used to report only the union's own path // ("expected object | undefined at $.order, got object"); the record - // arm's builder now reports where inside it the value fails. The cast - // is passed straight to a typed parameter, so it is checked at the - // cast: one that initializes a block-local binding continues as its - // parsed value instead (checked-cast fallback), as in Node. - const types = `interface Order { + // arm's builder now reports where inside it the value fails. + const r = await compileAndRun( + "optional-record-deep", + `interface Order { owner: { id: string; plan: { tier: string } }; total: number; } @@ -324,15 +323,10 @@ const texts = [ '{"order":{"owner":{"id":"u1","plan":{"tier":"pro"}},"total":3},"tags":["a",2]}', '{"order":5}', ]; -`; - const r = await compileAndRun( - "optional-record-deep", - `${types}function show(e: Partial): void { - console.log("ok", e.order?.owner.id); -} for (const text of texts) { try { - show(JSON.parse(text) as Partial); + const e = JSON.parse(text) as Partial; + console.log("ok", e.order?.owner.id); } catch (err) { if (err instanceof TypeError) console.log(err.message); } @@ -349,25 +343,6 @@ for (const text of texts) { "", ].join("\n"), ); - const fallback = await compileAndRun( - "optional-record-deep-fallback", - `${types}for (const text of texts) { - try { - const e = JSON.parse(text) as Partial; - console.log("ok", e.order?.owner.id); - } catch (err) { - if (err instanceof TypeError) console.log(err.message); - } -} -`, - "ts", - true, - ); - expect(fallback.stdout).toBe( - ["ok u1", "ok 7", "ok u1", "Cannot read properties of undefined (reading 'id')", ""].join( - "\n", - ), - ); }); test("JSON null matches nothing", async () => {