flagsmith-nodejs-client icon indicating copy to clipboard operation
flagsmith-nodejs-client copied to clipboard

Cannot use `DefaultFlag`

Open matthewelwell opened this issue 3 years ago • 1 comments

Both of the following snippets will log out undefined and attempting to instantiate a DefaultFlag object will throw an error, meaning that it's not possible to use the DefaultFlag constructor directly when defining default flag handler logic.

import { DefaultFlag } from "flagsmith-nodejs";

console.log(DefaultFlag);
const Flagsmith = require("flagsmith-nodejs");

console.log(Flagsmith.DefaultFlag);

matthewelwell avatar Mar 09 '23 17:03 matthewelwell

Note that the current solution is to simply return an object in the same shape as the DefaultFlag class:

const handler = (featureName) => {
    return { value: "foo", enabled: true, isDefault: true }
}

matthewelwell avatar Mar 09 '23 17:03 matthewelwell