Code Monkey home page Code Monkey logo

Comments (10)

zeh avatar zeh commented on May 25, 2024 2

@jcowman2 I think I've fixed it. It was missing a synthetic export. I managed to fix in another library of mine with a hack but somehow never realized it was missing in this library.

Anyway, I've published a new release. It shouldn't be breaking anything (old exports are still the same), but since this is somewhat of a big impact change, it's a new major version: 5.0.0.

Trying your repo with

npm install prando@latest --save
npm run test

Works well with the tests you had that were previously broken.

Can you try again?

from prando.

jcowman2 avatar jcowman2 commented on May 25, 2024 1

I've just confirmed, it works in my project now. Thanks so much for the help, @zeh ! 🎉

from prando.

zeh avatar zeh commented on May 25, 2024

Sorry I missed this earlier! Checking it this week. Weird as I have it working; might be due to my tsconfig settings.

Do you know if import * as Prando from 'prando'; works?

from prando.

jcowman2 avatar jcowman2 commented on May 25, 2024

I'm running into the same issue. When I try import * as Prando from 'prando';, I get the following TypeScript error:

Cannot use 'new' with an expression whose type lacks a call or construct signature..

from prando.

zeh avatar zeh commented on May 25, 2024

@jcowman2 @miso440 Do you have a link to any project that causes this error when attempting to import Prando? The reason I'm asking is because I've been unable to replicate it; my own projects that use the package still work with the latest version. I'm thinking this is somehow related to the tsconfig settings, but haven't been able to pinpoint what yet.

from prando.

jcowman2 avatar jcowman2 commented on May 25, 2024

@zeh Thanks for looking into this. Here's the branch of my project that's failing.

To replicate, clone + install dependencies, then run npm test. There should be a bunch failing with that same trace.

from prando.

zeh avatar zeh commented on May 25, 2024

@jcowman2 Thanks man, I'm taking a look.

from prando.

zeh avatar zeh commented on May 25, 2024

Identified the issue, more or less. It's when using TSC directly or, in your case, ts-node. They try resolving to the main file of package.json (the UMD export) rather than the module file (which would be more kosher) then it breaks. The funny thing is, importing the same UMD file through pure JavaScript works fine.

I haven't noticed that before because my standard builds use Webpack or similar packagers, and it works fine there. Apologies.

Still investigating, as it's likely we just need to export the UMD file in a way that is better understood by tsc.

Edit: more investigation: UMD modules with defaults are not properly imported by TypeScript because of this error. Compiling with esModuleInterop makes it possible to properly import Prando from "prando"; but of course requires a change in every project. Trying to see if there's a way to circumvent that during generation. In general it works with the current bundler (Rollup) with exports: named for the umd output, but then it breaks on JavaScript.

from prando.

zeh avatar zeh commented on May 25, 2024

Nice! Thank you for the report and the repro!

from prando.

zeh avatar zeh commented on May 25, 2024

Closed as this is fixed in v5.0.0.

from prando.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.