79287176

Date: 2024-12-17 08:43:25
Score: 1.5
Natty:
Report link

You could add satisfies keyof MyType

function getSharedProperty(obj: PossibleInputs): string | undefined {
    if ("assumedUnique" satisfies keyof IFirst in obj) {
        return "version 1 of the function";
    }

    // do some operation using obj.sharedPropertyName
    return obj.sharedPropertyName;
}

playground

Reasons:
  • Probably link only (1):
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Lex