Skip to content

Commit 2209b69

Browse files
Save Point
1 parent 3d87fe2 commit 2209b69

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

src/identity.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Constants, { HTTP_OK } from './constants';
2-
import Types from './types';
2+
import Types, { IdentityType } from './types';
33
import {
44
cacheOrClearIdCache,
55
createKnownIdentities,
@@ -17,7 +17,6 @@ import {
1717
isObject,
1818
} from './utils';
1919
import { hasMPIDAndUserLoginChanged, hasMPIDChanged } from './user-utils';
20-
import { IdentityType } from './types';
2120
import { processReadyQueue } from './pre-init-utils';
2221

2322
export default function Identity(mpInstance) {

src/sdkRuntimeModels.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from '@mparticle/web-sdk';
99
import { IStore } from './store';
1010
import Validators from './validators';
11-
import { Dictionary } from './utils';
11+
import { Dictionary, valueof } from './utils';
1212
import { IServerModel } from './serverModel';
1313
import { IKitConfigs } from './configAPIClient';
1414
import { SDKConsentApi, SDKConsentState } from './consent';
@@ -154,7 +154,7 @@ interface IEvents {
154154
export interface MParticleWebSDK {
155155
addForwarder(mockForwarder: MPForwarder): void;
156156
_IntegrationCapture: IntegrationCapture;
157-
IdentityType: typeof IdentityType;
157+
IdentityType: valueof<typeof IdentityType>;
158158
_Identity: IIdentity;
159159
Identity: SDKIdentityApi;
160160
Logger: SDKLoggerApi;

src/types.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Constants from './constants';
2-
import { parseNumber } from './utils';
2+
import { parseNumber, valueof } from './utils';
33

44
interface IdentitiesByType {
55
[key: number]: string;
@@ -87,7 +87,7 @@ export const EventType = {
8787
return 'Other';
8888
}
8989
},
90-
} as const;
90+
};
9191

9292
// Continuation of EventType enum above, but in seperate object since we don't expose these to end user
9393
export const CommerceEventType = {
@@ -131,7 +131,7 @@ export const IdentityType = {
131131

132132
isValid(identityType: number): boolean {
133133
if (typeof identityType === 'number') {
134-
for (var prop in IdentityType) {
134+
for (const prop in IdentityType) {
135135
if (IdentityType.hasOwnProperty(prop)) {
136136
if (IdentityType[prop] === identityType) {
137137
return true;
@@ -166,7 +166,7 @@ export const IdentityType = {
166166
}
167167
},
168168

169-
getIdentityType: (identityName: string): typeof IdentityType | boolean => {
169+
getIdentityType: (identityName: string): valueof<typeof IdentityType> | boolean => {
170170
switch (identityName) {
171171
case 'other':
172172
return IdentityType.Other;
@@ -264,10 +264,10 @@ export const IdentityType = {
264264
}
265265
},
266266

267-
getNewIdentitiesByName: (newIdentitiesByType: IdentitiesByType) => {
267+
getNewIdentitiesByName: (newIdentitiesByType: IdentitiesByType): IdentitiesByType => {
268268
const newIdentitiesByName: IdentitiesByType = {};
269269

270-
for (var key in newIdentitiesByType) {
270+
for (const key in newIdentitiesByType) {
271271
const identityNameKey = IdentityType.getIdentityName(
272272
parseNumber(key)
273273
);
@@ -384,7 +384,7 @@ export const ApplicationTransitionType = {
384384
AppInit: 1 as const,
385385
};
386386

387-
export default{
387+
export default {
388388
MessageType,
389389
EventType,
390390
CommerceEventType,

0 commit comments

Comments
 (0)