silentmatt / expr-eval

Mathematical expression evaluator in JavaScript
http://silentmatt.com/javascript-expression-evaluator/
MIT License
1.19k stars 239 forks source link

Cannot find module #224

Open ghost opened 4 years ago

ghost commented 4 years ago
import {Parser} from 'expr-eval'

const res = Parser.evaluate('3+2 * 5 ** power', {
    power: 2
})

console.log(res)

I've trying to implement expr-eval into my project today, which is written with Typescript. Then I encounter this problem. Maybe it's some problem with parser.d.ts ? Sorry I'm a newbie in coding. Thx very much for any helps! e120f93111291fd11173f48a947eac7

ghost commented 4 years ago

For some reasons, it works with require instead of import {...} from '...', but with the price of loosing all the juicy code hinting and stuff. Maybe I can try write with import and switch to require when compile, but then again it's possible to loose all the juicy type assertion Typescript provides when type error occurs.

silentmatt commented 4 years ago

Unfortunately I have almost no experience with TypeScript. It's something I'm interested in learning more about but haven't gotten to it yet. I'll try to play around with it when I get a chance and see if I can figure it out, but I won't be much help until then.