Code Monkey home page Code Monkey logo

Comments (7)

kachkaev avatar kachkaev commented on August 18, 2024 1

All works like a charm now! 😍 Many thanks for your time @brummelte!!!

from sleep-promise.

brummelte avatar brummelte commented on August 18, 2024

Tools like webpack support the "module" notation in package.json. So using TypeScript with webpack might work and use the esm-file. I've added type definitions for the esm-file. But I'm not sure if they will be loaded correctly. It seems like you can only define one entry file for types.

I can't seem to get TypeScript (without webpack) to work with the module syntax anyway. The following doesn't seem to work:

import sleep from 'sleep-promise/build/esm';

And I don't want to add a default export to the common js bundle. So I've reverted the types.

You now will have to import it as import * as sleep … with TypeScript. Adding --allowSyntheticDefaultImport might also work to get TypeScript to accept a default export.

I'm closing this for now, because this has cost me too much time already.

If anybody finds a way of adding default import compatibility for TypeScript without changing the commonJS file, I'm happy to take a look again.

from sleep-promise.

kachkaev avatar kachkaev commented on August 18, 2024

Thank you @brummelte! One final minor bit: could you please add !types/* to .npmignore? Otherwise, type definition files are not published and we're going back to #6 (comment) 😅

from sleep-promise.

brummelte avatar brummelte commented on August 18, 2024

Sorry :-)

!types/* not being added is correct. The path in package.json was wrong. Fixed now.

from sleep-promise.

abel-mak avatar abel-mak commented on August 18, 2024

You now will have to import it as import * as sleep … with TypeScript.

Hi @brummelte, shouldn't the README be updated accordingly

from sleep-promise.

brummelte avatar brummelte commented on August 18, 2024

@abel-mak it's only for TypeScript. If you can find a way to make TypeScript work with the default import, I'm happy to change it.

from sleep-promise.

abel-mak avatar abel-mak commented on August 18, 2024

@brummelte i see, thanks for responding!

from sleep-promise.

Related Issues (10)

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.