Skip to content

Instantly share code, notes, and snippets.

@crutchcorn
Created February 15, 2025 07:13
Show Gist options
  • Save crutchcorn/248320dd89c50564e6783bd2f86be45b to your computer and use it in GitHub Desktop.
Save crutchcorn/248320dd89c50564e6783bd2f86be45b to your computer and use it in GitHub Desktop.
interface Base {
// @ts-ignore
other: number extends this['val'] ? number : string;
}
interface Other<T = undefined> {
val?: T extends undefined ? number : T;
}
interface Test<T = undefined> extends Base, Other<T> {}
const t = 0 as never as Test<string>;
t.other;
// ^? t.other is `string`
const tt = 0 as never as Test
tt.other;
// ^? tt.other is `number`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment