You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
doStuff(value: IBaseClass): void
{
if (value is IFirstClass) {
//Do something with value.SomeProperty
}
}
I know that in order to do this, I need some type guarding code like this:
export function isFirstClass(item: IFirstClass | ISecondClass): item is IFirstClass {
return (<IFirstClass>item).SomeProperty !== undefined;
}
Writing it, is not a big deal as such, but I wanted to know if there are any built in options to generate this so I don't have to maintain it manually when the file is updated?
The text was updated successfully, but these errors were encountered:
Is it possible to write C# code to generate TypeScript type guards?
My case if the following:
and wanting to use it in a method like
I know that in order to do this, I need some type guarding code like this:
Writing it, is not a big deal as such, but I wanted to know if there are any built in options to generate this so I don't have to maintain it manually when the file is updated?
The text was updated successfully, but these errors were encountered: