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
constresult=awaitprovider.resolveObjectEvaluation('jsonFlag',{"prop": "default"},{ targetingKey }));// At this point, the inferred compile-time type of the `result` variable is `{ "prop": string }`, which may not be in sync with the actual run-time type.console.log(result.prop.length);// throws "TypeError: result.prop is undefined"
Since the default value type and the return value type is connected via the T type parameter, the inferred type of result will be { "prop": string } in the example above. However, when the value resolution is successful and an actual value is returned, nothing guarantees that the resolved value has a string property named "prop". Some of the providers not even guarantee that the returned value is an object.
Expected Behavior
In my opinion, the inferred type of result should be JsonValue, that is, the correct method signature should look like this:
This way the SDK wouldn't make a "false promise" and would force the caller to think about the return value type.
For example:
constresult=awaitprovider.resolveObjectEvaluation('jsonFlag',{"prop": "default"},{ targetingKey }));// At this point, the inferred compile-time type of the `result` variable is `JsonValue`, that is, caller needs to make checks or assertions on the actual run-time type.if(typeofresult==="object"&&typeofresult.prop==="string"){console.log(result.prop.length);}
Steps to reproduce
No response
The text was updated successfully, but these errors were encountered:
Observed behavior
Currently the TypeScript method signature of resolveObjectEvaluation makes a promise that the SDK cannot keep at run-time, which allows the caller to make mistakes.
For example:
Since the default value type and the return value type is connected via the
T
type parameter, the inferred type ofresult
will be{ "prop": string }
in the example above. However, when the value resolution is successful and an actual value is returned, nothing guarantees that the resolved value has a string property named "prop". Some of the providers not even guarantee that the returned value is an object.Expected Behavior
In my opinion, the inferred type of
result
should beJsonValue
, that is, the correct method signature should look like this:This way the SDK wouldn't make a "false promise" and would force the caller to think about the return value type.
For example:
Steps to reproduce
No response
The text was updated successfully, but these errors were encountered: