From a335a12bc9f0f1a44cceee887245c2258e1b99f6 Mon Sep 17 00:00:00 2001 From: Trevor Florence Date: Tue, 29 Nov 2022 08:07:46 -0700 Subject: [PATCH] Prevent the .not modifier from being chained (#20) --- src/index.ts | 2 +- test/types.test.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 2e4532b..f936b4e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -143,7 +143,7 @@ export interface ExpectTypeOf { ? never : ExpectTypeOf : never - not: ExpectTypeOf> + not: Omit>, 'not'> } const fn: any = () => true diff --git a/test/types.test.ts b/test/types.test.ts index 9e69af1..11fbe9b 100644 --- a/test/types.test.ts +++ b/test/types.test.ts @@ -70,6 +70,11 @@ test(`never types don't sneak by`, () => { expectTypeOf().toMatchTypeOf<{foo: string}>() }) +test('not cannot be chained', () => { + // @ts-expect-error + expectTypeOf().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,