Since version 6.2.2, there is a typescript issue when we build:
/node_modules/@types/tmp/index"' has no default export.
3 import tmp from 'tmp';
~~~
Found 1 error.
nothing really changed, only an import for tmp got removed (because double), so, do you have any more information? did you clear your node_modules already?
Addition: please add which package you are using
and:
I just ran into a similar issue.
> tsc
../../node_modules/mongodb-memory-server-core/lib/MongoMemoryServer.d.ts:3:17 - error TS7016: Could not find a declaration file for module 'tmp'. '../../node_modules/mongodb-memory-server-core/node_modules/tmp/lib/tmp.js' implicitly has an 'any' type.
Try `npm install @types/tmp` if it exists or add a new declaration (.d.ts) file containing `declare module 'tmp';`
3 import tmp from 'tmp';
~~~~~
Found 1 error.
Looking at the package.json for mongodb-memory-server-core, I see @types/tmp, but it is in devDependencies. Editing the installed package.json and moving "@types/tmp": "0.1.0", to dependencies will fix that.
Then I run into the issue above. There isn't a default export for @types/tmp, so changing the code to import * as tmp from 'tmp' should resolve it. The other alternative is consumers are required to have "allowSyntheticDefaultImports": true added to their tsconfig.json.
I would suggest not requiring the use of allowSyntheticDefaultImports along with moving any @types packages to dependencies if the lib is in dependencies. Both ensure consumers won't have to add any extra packages or change configs to use your package with TypeScript.
Recap:
@types/tmp to dependenciesimport tmp from 'tmp' to import * as tmp from 'tmp'but it is in devDependencies
this is by design, typescript type only packages should never be in anything other than devDependencies
That is not true at all actually. It was at one time the belief though. If you check out the npm page for @types/npm you will see the default instructions use --save and not --save-dev or yarn's -D.
Microsoft's TypeScript handbook says this about publishing:
Make sure all the declaration packages you depend on are marked appropriately in the "dependencies" section in your package.json.
(example project.json shown)
Here, our package depends on the browserify and typescript packages. browserify does not bundle its declaration files with its npm packages, so we needed to depend on @types/browserify for its declarations. typescript, on the other hand, packages its declaration files, so there was no need for any additional dependencies.Our package exposes declarations from each of those, so any user of our browserify-typescript-extension package needs to have these dependencies as well. For that reason, we used "dependencies" and not "devDependencies", because otherwise our consumers would have needed to manually install those packages. If we had just written a command line application and not expected our package to be used as a library, we might have used devDependencies
I don't recall when the recommended approach change, but I want to say it was 2017-2018.
With the latest changes, I'm no longer having the default export issue.
Closing because it is fixed by #265