|
1 | 1 | import Constants from './constants'; |
2 | | -import { parseNumber } from './utils'; |
| 2 | +import { parseNumber, valueof } from './utils'; |
3 | 3 |
|
4 | 4 | interface IdentitiesByType { |
5 | 5 | [key: number]: string; |
@@ -87,7 +87,7 @@ export const EventType = { |
87 | 87 | return 'Other'; |
88 | 88 | } |
89 | 89 | }, |
90 | | -} as const; |
| 90 | +}; |
91 | 91 |
|
92 | 92 | // Continuation of EventType enum above, but in seperate object since we don't expose these to end user |
93 | 93 | export const CommerceEventType = { |
@@ -131,7 +131,7 @@ export const IdentityType = { |
131 | 131 |
|
132 | 132 | isValid(identityType: number): boolean { |
133 | 133 | if (typeof identityType === 'number') { |
134 | | - for (var prop in IdentityType) { |
| 134 | + for (const prop in IdentityType) { |
135 | 135 | if (IdentityType.hasOwnProperty(prop)) { |
136 | 136 | if (IdentityType[prop] === identityType) { |
137 | 137 | return true; |
@@ -166,7 +166,7 @@ export const IdentityType = { |
166 | 166 | } |
167 | 167 | }, |
168 | 168 |
|
169 | | - getIdentityType: (identityName: string): typeof IdentityType | boolean => { |
| 169 | + getIdentityType: (identityName: string): valueof<typeof IdentityType> | boolean => { |
170 | 170 | switch (identityName) { |
171 | 171 | case 'other': |
172 | 172 | return IdentityType.Other; |
@@ -264,10 +264,10 @@ export const IdentityType = { |
264 | 264 | } |
265 | 265 | }, |
266 | 266 |
|
267 | | - getNewIdentitiesByName: (newIdentitiesByType: IdentitiesByType) => { |
| 267 | + getNewIdentitiesByName: (newIdentitiesByType: IdentitiesByType): IdentitiesByType => { |
268 | 268 | const newIdentitiesByName: IdentitiesByType = {}; |
269 | 269 |
|
270 | | - for (var key in newIdentitiesByType) { |
| 270 | + for (const key in newIdentitiesByType) { |
271 | 271 | const identityNameKey = IdentityType.getIdentityName( |
272 | 272 | parseNumber(key) |
273 | 273 | ); |
@@ -384,7 +384,7 @@ export const ApplicationTransitionType = { |
384 | 384 | AppInit: 1 as const, |
385 | 385 | }; |
386 | 386 |
|
387 | | -export default{ |
| 387 | +export default { |
388 | 388 | MessageType, |
389 | 389 | EventType, |
390 | 390 | CommerceEventType, |
|
0 commit comments