kuitos / axios-extensions

🍱 axios extensions lib, including throttle, cache, retry features etc...
MIT License
831 stars 49 forks source link

TypeScript: module '...lru-cache' has no default export #31

Closed tmladek closed 6 years ago

tmladek commented 6 years ago

Hello, as of today, with the latest version of both axios extensions and lru-cache, I get the following error while compiling with typescript:

ERROR in /.../node_modules/axios-extensions/lib/index.d.ts(6,8):
TS1192: Module '"/.../node_modules/@types/lru-cache/index"' has no default export.
Version: typescript 2.9.2

And it indeed is true; I had to change line

import Cache from 'lru-cache'; to import {Cache} from 'lru-cache';

And it compiles succesfully.

kuitos commented 6 years ago

have you ever enable the ts config esModuleInterop: true ?

tmladek commented 6 years ago

When I try to import Cache from 'lru-cache', enabling esModuleInterop fixes the issue; however, when I am not importing it directly, and only, for example import {cacheAdapterEnhancer} from 'axios-extensions', it doesn't matter what esModuleInterop is set to, I get the error.

tmladek commented 6 years ago

Minimal example here: https://gist.github.com/tmladek/2b25461159d60fe4568de85b071b73a3

kuitos commented 6 years ago

sorry, forgotten with the config "allowSyntheticDefaultImports": true,.. I will make a bit change for the unnecessary implicit configuration.

tmladek commented 6 years ago

Yes, "allowSyntheticDefaultImports": true does fix the issue. Thank you!

kuitos commented 6 years ago

Thanks for your feedback!

vfarah-if commented 1 year ago

I had tried with esModuleInterop: true and not the other value, will try now. Thanks hugely for the help guys and the quick response. Hopefully this is all good.