Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/hooks/useVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect } from 'react'

import { useAppStore } from '../store/useAppStore'
import { useVariableStore } from '../store/useVariableStore'
import { Parser } from 'expr-eval'
import { Parser, type Values } from 'expr-eval'

export function useVariables() {
const notes = useAppStore((state) => state.notes)
Expand All @@ -21,7 +21,7 @@ export function useVariables() {
while ((varMatch = reVar.exec(note.content)) !== null) {
const name = varMatch[1]
try {
globals[name] = parser.evaluate(varMatch[2], globals as Record<string, unknown>)
globals[name] = parser.evaluate(varMatch[2], globals as Values)
} catch (e) {
// eslint-disable-next-line no-console
console.error(`useVariables evaluation error for ${name}:`, e)
Expand Down
6 changes: 3 additions & 3 deletions src/lib/editor/MathEvaluator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { EditorView } from '@codemirror/view'
import { getScope } from './VariableScope'
import { Parser } from 'expr-eval'
import { Parser, type Values } from 'expr-eval'

export function evaluateMath(
docStr: string,
Expand All @@ -20,7 +20,7 @@ export function evaluateMath(
const expr = text.substring(0, text.lastIndexOf('=')).trim()
if (expr && !expr.startsWith('/var') && !expr.startsWith('/globvar')) {
try {
const result = String(parser.evaluate(expr, scope))
const result = String(parser.evaluate(expr, scope as Values))
changes.push({
from: offset + lineLen,
to: offset + lineLen,
Expand All @@ -45,7 +45,7 @@ export function evaluateMath(
const expr = exprPart.replace(/=\s*$/, '').trim()
if (expr) {
try {
const newResult = String(parser.evaluate(expr, scope))
const newResult = String(parser.evaluate(expr, scope as Values))
if (newResult !== oldResult) {
const startReplace = calcMatch.index + exprPart.length + 1 // +1 for \u200B
const endReplace = calcMatch.index + calcMatch[0].length
Expand Down
4 changes: 2 additions & 2 deletions src/lib/editor/VariableScope.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { EditorView } from '@codemirror/view'
import { StateEffect } from '@codemirror/state'
import { useVariableStore } from '../../store/useVariableStore'
import { Parser } from 'expr-eval'
import { Parser, type Values } from 'expr-eval'
import { MathEvaluator } from './MathEvaluator'

export const scopeChangedEffect = StateEffect.define<void>()
Expand Down Expand Up @@ -30,7 +30,7 @@ export class VariableScope {
const name = varMatch[1]
try {
const mergedScope = Object.assign({}, globalVars, newScope)
const val = parser.evaluate(varMatch[2], mergedScope as Record<string, unknown>)
const val = parser.evaluate(varMatch[2], mergedScope as Values)
newScope[name] = val
} catch (e) {
// eslint-disable-next-line no-console
Expand Down
2 changes: 1 addition & 1 deletion src/lib/safeStorage.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach } from 'vitest'
import { describe, it, expect, beforeEach, vi } from 'vitest'
import { setSecure, getSecure } from './safeStorage'

describe('safeStorage (Renderer Flow)', () => {
Expand Down
Loading