Skip to content

Commit

Permalink
Prevent the .not modifier from being chained (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorade authored Nov 29, 2022
1 parent dcd6422 commit a335a12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export interface ExpectTypeOf<Actual, B extends boolean> {
? never
: ExpectTypeOf<T, B>
: never
not: ExpectTypeOf<Actual, Not<B>>
not: Omit<ExpectTypeOf<Actual, Not<B>>, 'not'>
}
const fn: any = () => true

Expand Down
5 changes: 5 additions & 0 deletions test/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ test(`never types don't sneak by`, () => {
expectTypeOf<never>().toMatchTypeOf<{foo: string}>()
})

test('not cannot be chained', () => {
// @ts-expect-error
expectTypeOf<number>().not.not.toBeNumber()
})

test('constructor params', () => {
// The built-in ConstructorParameters type helper fails to pick up no-argument overloads.
// This test checks that's still the case to avoid unnecessarily maintaining a workaround,
Expand Down

0 comments on commit a335a12

Please sign in to comment.