mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
27 lines
356 B
TypeScript
27 lines
356 B
TypeScript
// @strict: true
|
|
// @noEmit: true
|
|
|
|
// https://github.com/microsoft/typescript-go/issues/986
|
|
|
|
interface A {
|
|
type: "a";
|
|
}
|
|
|
|
interface B {
|
|
type: "b";
|
|
}
|
|
|
|
interface Types {
|
|
a: A;
|
|
b: B;
|
|
}
|
|
|
|
export function exhaustiveSwitch<T extends keyof Types>(type: T): boolean {
|
|
switch (type) {
|
|
case "a":
|
|
return true;
|
|
case "b":
|
|
return true;
|
|
}
|
|
}
|