-
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.
Make Logger contravariant over the log type (#17)
- Loading branch information
Showing
6 changed files
with
28 additions
and
11 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
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,17 @@ | ||
import {Log, Logger} from '../src'; | ||
|
||
declare function make<T>(): T; | ||
|
||
declare function receive<T>(x: T): void; | ||
|
||
type TestLog = Log<{ | ||
foo: string, | ||
}>; | ||
|
||
// Covariance Log test: | ||
// A custom Log type must be assignable to the base logger type. | ||
receive<Log>(make<TestLog>()); | ||
|
||
// Contravariance Logger test: | ||
// A base logger must be assignable to a logger with a custom Log type. | ||
receive<Logger<TestLog>>(make<Logger>()); |
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 |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
"exclude": [ | ||
"node_modules", | ||
"build", | ||
"**/*.test.ts" | ||
"test/**/*.ts" | ||
] | ||
} |