Skip to content

Commit

Permalink
refactor: add non-null assertion instead of object spread
Browse files Browse the repository at this point in the history
  • Loading branch information
syi0808 committed Jul 1, 2024
1 parent 43392a2 commit e8e52ee
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions packages/vitest/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,16 +454,8 @@ export function resolveConfig(
] as const satisfies [keyof PoolOptions, keyof ThreadsOptions][]

for (const [poolOptionKey, workerOptionKey] of poolThreadsOptions) {
const workerInlineOption = resolved.poolOptions?.[poolOptionKey]?.[workerOptionKey]

if (workerInlineOption) {
resolved.poolOptions = {
...resolved.poolOptions,
[poolOptionKey]: {
...resolved.poolOptions?.[poolOptionKey],
[workerOptionKey]: resolveInlineWorkerOption(workerInlineOption),
},
}
if (resolved.poolOptions?.[poolOptionKey]?.[workerOptionKey]) {
resolved.poolOptions[poolOptionKey]![workerOptionKey] = resolveInlineWorkerOption(resolved.poolOptions[poolOptionKey]![workerOptionKey]!)
}
}

Expand All @@ -475,16 +467,8 @@ export function resolveConfig(
] as const satisfies [keyof PoolOptions, keyof ForksOptions][]

for (const [poolOptionKey, workerOptionKey] of poolForksOptions) {
const workerInlineOption = resolved.poolOptions?.[poolOptionKey]?.[workerOptionKey]

if (workerInlineOption) {
resolved.poolOptions = {
...resolved.poolOptions,
[poolOptionKey]: {
...resolved.poolOptions?.[poolOptionKey],
[workerOptionKey]: resolveInlineWorkerOption(workerInlineOption),
},
}
if (resolved.poolOptions?.[poolOptionKey]?.[workerOptionKey]) {
resolved.poolOptions[poolOptionKey]![workerOptionKey] = resolveInlineWorkerOption(resolved.poolOptions[poolOptionKey]![workerOptionKey]!)
}
}

Expand Down

0 comments on commit e8e52ee

Please sign in to comment.