-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error TS2665: Invalid module name in augmentation in jest/async-storage-mock #746
Comments
Hi @fqborges, do you know which version of TypeScript you're using? And do you have a repo where this reproduces? It's odd that we didn't see this during testing. Edit: FWIW, I imported 1.16 in a project of ours and don't see this error message. We're using TypeScript 4.5.5. |
Wow, I cant reproduce in a fresh react-native app. I will try again later. I will extract a mre from my private repo.
Thanks. |
I am getting the same error. |
same issue here since upgrading from
|
I confirm, the error appears with 1.16.
|
Do you have a public repo where this occurs? As I mentioned above, I cannot repro this error. Edit: Also, please make sure you retry after cleaning out caches and the like. OP was also unable to repro in a fresh RN app. |
I had this error happen on version 15, and upgraded to 16 hoping it will fix it. It did not. I'll see if I can figure out the issue. |
I just noticed that I don't have the issue that the author has. BUT the issue that the author has seems to come from trying to solves this. I'm getting:
If I then add
So... the original issue probably isn't the root cause. It's also really weird, I found the initial import to sometimes work, and suddenly stop (in new project). Or it could be a weird caching thing, from VSCode or whatever. But the following docker container reproduces my issue, every time (at least for me). Ah, and it is noteworthy to say, that I do not put the mock into the jest setup file, like stated here: https://react-native-async-storage.github.io/async-storage/docs/advanced/jest/#with-jest-setup-file. I just import it in the tests that require the mock. InstructionsCreate a random directory and place the following files inside it:
|
Using diff --git a/node_modules/@react-native-async-storage/async-storage/lib/typescript/index.d.ts b/node_modules/@react-native-async-storage/async-storage/lib/typescript/index.d.ts
index 82f4649..4847a4a 100644
--- a/node_modules/@react-native-async-storage/async-storage/lib/typescript/index.d.ts
+++ b/node_modules/@react-native-async-storage/async-storage/lib/typescript/index.d.ts
@@ -3,8 +3,3 @@ import type { AsyncStorageHook, AsyncStorageStatic } from './types';
export { useAsyncStorage } from './hooks';
export type { AsyncStorageStatic } from './types';
export default AsyncStorage;
-declare module '@react-native-async-storage/async-storage/jest/async-storage-mock' {
- export function useAsyncStorage(key: string): AsyncStorageHook;
- const AsyncStorageLib: AsyncStorageStatic;
- export default AsyncStorageLib;
-} is my workaround until this is fixed |
This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed. |
Expo 45 is out which uses this version, so just hit it. If people are having issues reproducing, make sure |
Hi folks, sorry it took so long to get back to you on this. Like I said earlier, I couldn't repro this locally. However, I did get a different error when I imported the module directly in source. Please check out #805 and let me know if it fixes the issue for you. |
🎉 This issue has been resolved in version 1.17.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Can confirm it works fine now, thanks! 👍 |
What happened?
Just upgraded to 1.16.0, my typescript builds started to error with:
Version
1.16.0
What platforms are you seeing this issue on?
System Information
Steps to Reproduce
yarn install "@react-native-async-storage/[email protected]
yarn tsc
The text was updated successfully, but these errors were encountered: