Comments (7)
All works like a charm now! 😍 Many thanks for your time @brummelte!!!
from sleep-promise.
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.
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.
Sorry :-)
!types/*
not being added is correct. The path in package.json was wrong. Fixed now.
from sleep-promise.
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.
@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.
@brummelte i see, thanks for responding!
from sleep-promise.
Related Issues (10)
- Does not work when using sinon.useFakeTimers() HOT 10
- Feature request: cancel promise HOT 10
- Dependency Dashboard
- Add JSDoc/TSDoc comment to methods HOT 1
- Provides a helper to delay a promise chain HOT 3
- Example shows default import, but none is present HOT 1
- TypeScript typings HOT 5
- A release without core-js HOT 1
- Action Required: Fix Renovate Configuration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sleep-promise.