Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent the .not modifier from being chained #20

Merged
merged 1 commit into from Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.ts
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
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