Skip to content

Commit 70f678d

Browse files
committed
Add a deprecation warning environment, restHost and realtimeHost client options
These client options have been deprecated in [1] if favor of the new `ClientOptions.endpoint` parameter. They were marked as deprecated only in the type declaration file, meaning that non-TypeScript users wouldn't see the deprecation warning. This PR adds an explicit deprecation warning log message when using these deprecated client options. [1] #1973
1 parent 6f2b7e6 commit 70f678d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/common/lib/util/defaults.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,21 @@ export function normaliseOptions(
274274
MsgPack: MsgPack | null,
275275
logger: Logger | null, // should only be omitted by tests
276276
): NormalisedClientOptions {
277-
checkIfClientOptionsAreValid(options);
278-
279277
const loggerToUse = logger ?? Logger.defaultLogger;
280278

279+
// Deprecated options
280+
if (options.environment) {
281+
loggerToUse.deprecated('The `environment` client option', 'Use the `endpoint` client option instead.');
282+
}
283+
if (options.restHost) {
284+
loggerToUse.deprecated('The `restHost` client option', 'Use the `endpoint` client option instead.');
285+
}
286+
if (options.realtimeHost) {
287+
loggerToUse.deprecated('The `realtimeHost` client option', 'Use the `endpoint` client option instead.');
288+
}
289+
290+
checkIfClientOptionsAreValid(options);
291+
281292
if (typeof options.recover === 'function' && options.closeOnUnload === true) {
282293
Logger.logAction(
283294
loggerToUse,

0 commit comments

Comments
 (0)