-
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: ✨ Add the Extends type - Check if one type extends from another
- Loading branch information
1 parent
99a88c6
commit 5566ad6
Showing
3 changed files
with
27 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@crbroughton/ts-test-utils": minor | ||
--- | ||
|
||
Add the Extends type - Check if one type extends from another |
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,20 @@ | ||
/* eslint-disable unused-imports/no-unused-vars */ | ||
import { describe, it } from 'bun:test' | ||
import type { Expect, Extends } from '..' | ||
|
||
describe('Extends tests', () => { | ||
it('Passes the extend test when the resulting type extends another type', () => { | ||
interface BaseType { id: number } | ||
type ExtensionType = BaseType & { name: string } | ||
type Result = Expect<Extends<BaseType, ExtensionType>> | ||
// ^? | ||
}) | ||
it('Failed the includes test when the resulting type does not include the sub-type', () => { | ||
// @ts-expect-error - Object / Record failing the equality checker | ||
type Result = Expect<Includes<{ id: number, name: string }, { hobby: string }>> | ||
// ^? | ||
}) | ||
}) | ||
|
||
|
||
|