Created
March 6, 2023 12:08
-
-
Save omril1/8d460c9a2b84a50955a4a4eed2e37925 to your computer and use it in GitHub Desktop.
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
interface Foo { | |
a: 'a'; | |
foobar?: 'foo1'; | |
} | |
interface Bar { | |
a: 'a'; | |
foobar?: 'foo2'; | |
} | |
interface OneOf { | |
a: 'a'; | |
} | |
function a(p: Foo) { | |
p.foobar = 'foo1'; | |
b(p); | |
} | |
function b(p: OneOf) { | |
c(p); | |
} | |
function c(p: Bar) { | |
// eslint-disable-next-line no-unused-expressions | |
p.foobar; | |
// ^ type is 'foo2' | undefined, but value is foo1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment