Skip to content

Instantly share code, notes, and snippets.

@omril1
Created March 6, 2023 12:08
Show Gist options
  • Save omril1/8d460c9a2b84a50955a4a4eed2e37925 to your computer and use it in GitHub Desktop.
Save omril1/8d460c9a2b84a50955a4a4eed2e37925 to your computer and use it in GitHub Desktop.
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