Closed SevenOutman closed 1 month ago
In the docs for the waitForInitialization method, it says:
It is not recommended to use the returned client object. It will be removed in a future version.
FYI.
Hello @SevenOutman,
As @chadxz mentioned we have updated the docs to indicate the return value here will be removed in the future.
Some previous discussion: https://github.com/launchdarkly/js-core/issues/324
I would recommend something like this instead.
export async function initLdClient(): Promise<ld.LDClient> {
const client = ld.init(process.env.LAUNCH_DARKLY_SDK_KEY as string);
await client.waitForInitialization();
return client;
}
(The fix is nice though.)
Thank you, Ryan
Understood. Thanks both! I'm closing the PR.
Requirements
Related issues
https://github.com/launchdarkly/js-core/issues/324
Describe the solution you've provided
Type the return type with
this
keywordDescribe alternatives you've considered
Additional context
In my use case, the problem was that the return type of
waitForInitialization
is not compatible withld.LDClient