📅  最后修改于: 2022-03-11 14:48:15.710000             🧑  作者: Mango
import { is } from 'typescript-is';
...
const getText = (obj: Obj1 | Obj2): string => {
if (is(obj)) {
return obj1.message;
}
return obj2.text;
};