Created
January 17, 2020 00:36
-
-
Save lafiosca/5020ecc4388c3feb60e4a0e7eb410918 to your computer and use it in GitHub Desktop.
Inconsistent type inference of object or 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
const foo = (x: unknown) => { // function(x: unknown): object | null | |
if (x === null || typeof x !== 'object') { | |
throw Error(); | |
} | |
return x; | |
}; | |
const bar = (x: unknown) => { // function(x: unknown): object | |
if (typeof x !== 'object' || x === null) { | |
throw Error(); | |
} | |
return x; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment