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
The change here adds these... useless to me but no objection:
+exportfunctionisCognitoId(obj: any,_argumentName?: string): obj is CognitoId{+returntypeofobj==="string";+}++exportfunctionisDeviceId(obj: any,_argumentName?: string): obj is DeviceId{+returntypeofobj==="string";+}
But then every single string comparison is again calling isCognitoId. Here's a example diff:
exportfunctionisRelationship(obj: any,_argumentName?: string): obj is Relationship{return(((obj!==null&&typeofobj==="object")||typeofobj==="function")&&-typeofobj.userId==="string"&&-typeofobj.deviceId==="string"+(isCognitoId(obj.userId)asboolean)&&+(isCognitoId(obj.deviceId)asboolean));}
isCognitoId(obj.deviceId) is functional, but absolutely misleading. I don't think this in an opinionated issue. It isn't just string, every primitive type now calls the function for the first alias to it.
Please either call the correct guard (isDeviceId), or restore my fix to use typeof for primitives within objects.
Possible solutions:
Just never reuse generated type guards at all, instead generate a giant function for the full depth of objects.
Never reuse primitive type guards (similar to @kernwig's fix, but only affecting reuse of guards, not actual generation of guards).
Be aware of the specific symbol that is being queried and select the right type guard
I'm pretty flat out at present so I won't be doing this one unless the mood takes me, but feel free to chime in if you have thoughts.
The text was updated successfully, but these errors were encountered:
Reported by @kernwig: #183 (comment)
Possible solutions:
I'm pretty flat out at present so I won't be doing this one unless the mood takes me, but feel free to chime in if you have thoughts.
The text was updated successfully, but these errors were encountered: