EricSmekens / jsep

JavaScript Expression Parser
http://ericsmekens.github.io/jsep/
MIT License
835 stars 136 forks source link

Error - Module '"jsep"' has no exported member 'Jsep' #237

Open HimanshuGoel opened 1 year ago

HimanshuGoel commented 1 year ago

I am getting an error Module '"jsep"' has no exported member 'Jsep' while importing the Jsep library by using the below statement -

import { Jsep } from 'jsep';

image

I am using the 1.3.8 version of Jsep library in a standard Angular 15 application.

However, it works fine when I use the default import syntax -

import jsep from 'jsep';

I have also created a minimal reproduction example on Github. Please refer to this link to open it on Stackblitz - https://stackblitz.com/github/HimanshuGoel/issues-reproduction-app/tree/jsep-issue-with-import?file=src%2Fapp%2Fapp.component.ts

benatkin commented 1 year ago

Looks like Jsep isn't included in TypeScript, but both of these work:

import * as jsep from 'jsep'
const { Jsep } = jsep
console.log(Jsep.parse('1 + 1'))
import { Jsep } from 'jsep'
console.log(Jsep.parse('1 + 1'))

If you look at the git log, it looks like the types are manually built: https://github.com/EricSmekens/jsep/commits/master/typings/tsd.d.ts

6utt3rfly commented 1 year ago

198 proposed some updates to the typings, but the review comments indicate that it broke some of the other usages of jsep with cjs and esm. Would be great if someone wanted to create a PR?

benatkin commented 1 year ago

I suggest just using the jsep() API.

I don't have a use case for being able to use Jsep.parse in TypeScript the but I might have a use case for #211. I don't know yet. I think a fix for #211 could make this one easier.