Skip to content

Commit

Permalink
refactor(table): pull out type definition
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber committed Apr 27, 2024
1 parent 3f81566 commit 301773e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/@ourworldindata/core-table/src/CoreTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,13 @@ export class CoreTable<
// Otherwise, operations like `.concat()` will break in unexpected ways.
// See https://github.com/mobxjs/mobx/blob/mobx4and5/docs/best/pitfalls.md
// Also, see https://github.com/owid/owid-grapher/issues/2948 for an issue caused by this problem.
type CoreValueArrayThatMayBeMobxProxy = CoreValueType[] & {
toJS?: () => CoreValueType[]
}

for (const [slug, values] of Object.entries(columnStore)) {
const valuesThatMayBeMobxProxy = values as CoreValueType[] & {
toJS?: () => CoreValueType[]
}
const valuesThatMayBeMobxProxy =
values as CoreValueArrayThatMayBeMobxProxy
if (typeof valuesThatMayBeMobxProxy.toJS === "function") {
columnStore[slug] = valuesThatMayBeMobxProxy.toJS()
}
Expand Down

0 comments on commit 301773e

Please sign in to comment.