Answers for "union type property does not exist"

-1

union type property does not exist

import { is } from 'typescript-is';

...

const getText = (obj: Obj1 | Obj2): string => {
  if (is<Obj1>(obj)) {
    return obj1.message;
  }

  return obj2.text;
};
Posted by: Guest on January-14-2021

Code answers related to "union type property does not exist"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language