so I have
type newType = ResourcesKey | string;
enum ResourcesKey {
FirstString= 'path',
...
}
I then have a function that takes the instance and I want to test if it's a string or an enum, but in typescript are the two considered the same?
Function(instance: newType)
{
if (instance instanceof ResourcesKey) {
}
}
this returns an error error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
is there anything I can do to compare the instance to the type of the enum?
for example in C# I would probably be able to do something like
if (typeof (instance) == ResourcesKey) {
}
I can work around it of course, but I'm wondering what the preferred course of action is
instanceis one of enum values, you can go with something likeObject.values(ResourcesKey).includes(instance)