-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🔖 0.4.0 - Add the IsNullable and IsNonNullable types - Check if…
… a type is nullable or not
- Loading branch information
1 parent
1e5ca20
commit 1ba9db2
Showing
6 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable unused-imports/no-unused-vars */ | ||
import { describe, it } from 'bun:test' | ||
import type { Expect, IsNonNullable } from '../index' | ||
|
||
describe('IsNonNulable tests', () => { | ||
it('Passes the IsNonNulable test when the type is not nullable', () => { | ||
type Result = Expect<IsNonNullable<{ id: number }>> | ||
// ^? | ||
}) | ||
it('Failed the IsNonNulable test when the type is nullable', () => { | ||
// @ts-expect-error - Fails the IsNonNulable test | ||
type Result = Expect<IsNonNullable<{ id: string } | null>> | ||
// ^? | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable unused-imports/no-unused-vars */ | ||
import { describe, it } from 'bun:test' | ||
import type { Expect, IsNullable } from '../index' | ||
|
||
describe('IsNullable tests', () => { | ||
it('Passes the IsNullable test when the type is nullable', () => { | ||
type Result = Expect<IsNullable<{ id: number } | null>> | ||
// ^? | ||
}) | ||
it('Failed the IsNullable test when the type is not nullable', () => { | ||
// @ts-expect-error - Fails the exclusion | ||
type Result = Expect<IsNullable<{ id: string }>> | ||
// ^? | ||
}) | ||
}) |