Skip to content

Commit

Permalink
Don't rely on broken expect.error()
Browse files Browse the repository at this point in the history
  • Loading branch information
kanongil committed Dec 28, 2023
1 parent b801fae commit 316d8c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions test/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
Expand Down
4 changes: 2 additions & 2 deletions test/types/errors/test/restrict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 316d8c1

Please sign in to comment.