Skip to content

Commit eb780f7

Browse files
committed
ref: prefer object.entries
1 parent 29038e6 commit eb780f7

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

packages/form-core/src/FieldApi.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,41 +1324,44 @@ export class FieldApi<
13241324

13251325
return () => {
13261326
// Stop any in-flight async validation or listener work tied to this instance.
1327-
for (const key of Object.keys(
1327+
for (const [key, timeout] of Object.entries(
13281328
this.timeoutIds.validations,
1329-
) as ValidationCause[]) {
1330-
const timeout = this.timeoutIds.validations[key]
1329+
)) {
13311330
if (timeout) {
13321331
clearTimeout(timeout)
1333-
this.timeoutIds.validations[key] = null
1332+
this.timeoutIds.validations[
1333+
key as keyof typeof this.timeoutIds.validations
1334+
] = null
13341335
}
13351336
}
1336-
for (const key of Object.keys(
1337-
this.timeoutIds.listeners,
1338-
) as ListenerCause[]) {
1339-
const timeout = this.timeoutIds.listeners[key]
1337+
for (const [key, timeout] of Object.entries(this.timeoutIds.listeners)) {
13401338
if (timeout) {
13411339
clearTimeout(timeout)
1342-
this.timeoutIds.listeners[key] = null
1340+
this.timeoutIds.listeners[
1341+
key as keyof typeof this.timeoutIds.listeners
1342+
] = null
13431343
}
13441344
}
1345-
for (const key of Object.keys(
1345+
for (const [key, timeout] of Object.entries(
13461346
this.timeoutIds.formListeners,
1347-
) as ListenerCause[]) {
1348-
const timeout = this.timeoutIds.formListeners[key]
1347+
)) {
13491348
if (timeout) {
13501349
clearTimeout(timeout)
1351-
this.timeoutIds.formListeners[key] = null
1350+
this.timeoutIds.formListeners[
1351+
key as keyof typeof this.timeoutIds.formListeners
1352+
] = null
13521353
}
13531354
}
13541355

13551356
const fieldInfo = this.form.fieldInfo[this.name]
13561357

1357-
for (const key of Object.keys(fieldInfo.validationMetaMap) as Array<
1358-
keyof typeof fieldInfo.validationMetaMap
1359-
>) {
1360-
fieldInfo.validationMetaMap[key]?.lastAbortController.abort()
1361-
fieldInfo.validationMetaMap[key] = undefined
1358+
for (const [key, validationMeta] of Object.entries(
1359+
fieldInfo.validationMetaMap,
1360+
)) {
1361+
validationMeta?.lastAbortController.abort()
1362+
fieldInfo.validationMetaMap[
1363+
key as keyof typeof fieldInfo.validationMetaMap
1364+
] = undefined
13621365
}
13631366

13641367
// If a newer field instance has already been mounted for this name,

0 commit comments

Comments
 (0)