Description
Description
The documentation for getFeatureVariable over on https://docs.developers.optimizely.com/full-stack-experimentation/docs/get-feature-variable-javascript-node#section-generic says that this function will return a boolean, integer, double, or string depending on what it sees stored, but the return type is marked as unknown
.
This should be boolean | number | string | null
, instead. Or, even better, an OptimizelyVariableType
with an exported type definition export type OptimizelyVariableType = boolean | number | string | null;
that other code can import and work with as needed.
Benefits
Since the return type for getFeatureVariable
isn't unknown, but is very much known, making the typing reflect that would be super useful for folks who are writing their own mocks/clients with typing based on what the documentation claims may be returned.
Risks/Downsides
unknown
is incompatible with everything except another unknown
, so by updating the return typing to only those types that might actually be returned by the function, there shouldn't be any downsides. Only upsides.