Answers for "property does not exist on type. property does not exist on type union type typescript"

-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 "property does not exist on type. property does not exist on type union type typescript"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language