union type property does not exist

The solution for “union type property does not exist” can be found here. The following code will assist you in solving the problem.

import { is } from ‘typescript-is’;

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

return obj2.text;
};

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in