Skip to content

Commit 664fdb8

Browse files
committed
Convert user_profile_service_validator module to TS
1 parent e1976ef commit 664fdb8

File tree

2 files changed

+7
-10
lines changed
  • packages/optimizely-sdk/lib

2 files changed

+7
-10
lines changed

packages/optimizely-sdk/lib/optimizely/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { buildConversionEvent, buildImpressionEvent } from '../core/event_builde
2525
import eventTagsValidator from '../utils/event_tags_validator';
2626
import notificationCenter from '../core/notification_center';
2727
import projectConfig from '../core/project_config';
28-
import userProfileServiceValidator from '../utils/user_profile_service_validator';
28+
import * as userProfileServiceValidator from '../utils/user_profile_service_validator';
2929
import * as stringValidator from '../utils/string_value_validator';
3030
import projectConfigManager from '../core/project_config/project_config_manager';
3131

packages/optimizely-sdk/lib/utils/user_profile_service_validator/index.js renamed to packages/optimizely-sdk/lib/utils/user_profile_service_validator/index.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,20 @@
2121
import { sprintf } from '@optimizely/js-sdk-utils';
2222

2323
import { ERROR_MESSAGES } from '../enums';
24-
var MODULE_NAME = 'USER_PROFILE_SERVICE_VALIDATOR';
24+
25+
const MODULE_NAME = 'USER_PROFILE_SERVICE_VALIDATOR';
2526

2627
/**
2728
* Validates user's provided user profile service instance
28-
* @param {Object} userProfileServiceInstance
29-
* @return {boolean} True if the instance is valid
29+
* @param {object} userProfileServiceInstance
30+
* @return {boolean} true if the instance is valid
3031
* @throws If the instance is not valid
3132
*/
32-
export var validate = function(userProfileServiceInstance) {
33+
export function validate(userProfileServiceInstance: Record<string, unknown>): boolean {
3334
if (typeof userProfileServiceInstance.lookup !== 'function') {
3435
throw new Error(sprintf(ERROR_MESSAGES.INVALID_USER_PROFILE_SERVICE, MODULE_NAME, "Missing function 'lookup'"));
3536
} else if (typeof userProfileServiceInstance.save !== 'function') {
3637
throw new Error(sprintf(ERROR_MESSAGES.INVALID_USER_PROFILE_SERVICE, MODULE_NAME, "Missing function 'save'"));
3738
}
3839
return true;
39-
};
40-
41-
export default {
42-
validate: validate,
43-
};
40+
}

0 commit comments

Comments
 (0)