From 316d8c1b259ab323bafe696317ed05a353743e62 Mon Sep 17 00:00:00 2001 From: Gil Pedersen Date: Thu, 28 Dec 2023 20:50:23 +0100 Subject: [PATCH] Don't rely on broken expect.error() --- test/types.js | 12 ++++++++++++ test/types/errors/test/restrict.ts | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/types.js b/test/types.js index b3ee5538..48fc376a 100755 --- a/test/types.js +++ b/test/types.js @@ -98,6 +98,18 @@ describe('Types', () => { line: 3, column: 4 }, + { + filename: 'test/restrict.ts', + message: `Type 'undefined' is not assignable to type 'string' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target.`, + line: 10, + column: 0 + }, + { + filename: 'test/restrict.ts', + message: `'unchecked.b' is possibly 'undefined'.`, + line: 15, + column: 0 + }, { filename: 'test/syntax.ts', message: `')' expected.`, diff --git a/test/types/errors/test/restrict.ts b/test/types/errors/test/restrict.ts index a81be119..4705a9d0 100644 --- a/test/types/errors/test/restrict.ts +++ b/test/types/errors/test/restrict.ts @@ -7,9 +7,9 @@ const exact: UsesExactOptionalPropertyTypes = { a: true }; exact.a = undefined; exact.b = 'ok'; -expect.error(exact.b = undefined); +exact.b = undefined; // Fails const unchecked: UncheckedIndexedAccess = { a: exact, b: {} }; unchecked.a.a; -expect.error(unchecked.b.a); +unchecked.b.a; // Fails