Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
lantua committed Aug 18, 2024
1 parent 59aeb39 commit b74cd58
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion libs/gi/formula/src/calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type MemRec<V> = Partial<Record<Member, V>>
type CondInfo = MemRec<MemRec<Partial<Record<Sheet, Record<string, number>>>>>

export type CalcMeta = PartialMeta & Info & { [reusable]?: true }
type PartialMeta = {
export type PartialMeta = {
tag?: Tag
op: 'const' | 'sum' | 'prod' | 'min' | 'max' | 'sumfrac' | 'res'
ops: CalcResult<number, PartialMeta>[]
Expand Down
9 changes: 5 additions & 4 deletions libs/gi/formula/src/formulaText.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { CalcResult } from '@genshin-optimizer/pando/engine'
import type { CalcMeta } from './calculator'
import type { PartialMeta } from './calculator'

type Output = PartialMeta
type FormulaText = {
name: string | undefined
formula: string
Expand All @@ -10,8 +11,8 @@ type FormulaText = {
deps: FormulaText[]
}
export function translate(
data: CalcResult<number, CalcMeta>,
cache: Map<CalcResult<number, CalcMeta>, FormulaText> = new Map()
data: CalcResult<number, Output>,
cache: Map<CalcResult<number, Output>, FormulaText> = new Map()
): FormulaText {
const old = cache.get(data)
if (old) return old
Expand All @@ -22,7 +23,7 @@ export function translate(

const deps = new Set<FormulaText>()
function getString(
ops: CalcResult<number, CalcMeta>[],
ops: CalcResult<number, Output>[],
prec: number // precedence of the encompassing/parent term
): string[] {
return ops.map((op) => {
Expand Down
2 changes: 1 addition & 1 deletion libs/sr/formula/src/calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type MemRec<V> = Partial<Record<Member, V>>
type CondInfo = MemRec<MemRec<Partial<Record<Sheet, Record<string, number>>>>>

export type CalcMeta = PartialMeta & Info & { [reusable]?: true }
type PartialMeta = {
export type PartialMeta = {
tag?: Tag
op: 'const' | 'sum' | 'prod' | 'min' | 'max' | 'sumfrac' | 'res'
ops: CalcResult<number, PartialMeta>[]
Expand Down
7 changes: 2 additions & 5 deletions libs/sr/formula/src/formulaText.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import type { CalcResult } from '@genshin-optimizer/pando/engine'
import type { Tag } from './data/util'
import type { PartialMeta } from './calculator'

type Output = {
tag: Tag | undefined
op: 'const' | 'sum' | 'prod' | 'min' | 'max' | 'sumfrac'
ops: CalcResult<number, Output>[]
}
type Output = PartialMeta

type FormulaText = {
name: string | undefined
Expand Down

0 comments on commit b74cd58

Please sign in to comment.