Skip to content
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

5.3.0 is not compatible with Expo FileSystem #112

Open
trajano opened this issue Oct 29, 2024 · 2 comments
Open

5.3.0 is not compatible with Expo FileSystem #112

trajano opened this issue Oct 29, 2024 · 2 comments

Comments

@trajano
Copy link

trajano commented Oct 29, 2024

This example used to work

import * as FileSystem from 'expo-file-system';
import { InteractionManager } from 'react-native';
import { fileAsyncTransport, logger } from 'react-native-logs';

const consoleLog = logger.createLogger({
  transport: fileAsyncTransport,
  transportOptions: {
    FS: FileSystem,
    fileName: `logs_${new Date().toLocaleDateString()}.txt`,
  },
  asyncFunc: InteractionManager.runAfterInteractions,
});

But now it's complaining that

error TS2322: Type 'typeof import("C:/p/expo-experiments/node_modules/expo-file-system/build/index")' is not assignable to type 'RNFS | EXPOFS'.
Type 'typeof import("C:/p/expo-experiments/node_modules/expo-file-system/build/index")' is missing the following properties from type 'EXPOFS': DocumentDirectoryPath, appendFile

@trajano
Copy link
Author

trajano commented Oct 29, 2024

What you likely need to do is remove the never lines in the type at least to get it to pass the typing.

  DocumentDirectoryPath: never;

@tmac24utm
Copy link

Same issue with RNFS, the type definitions in fileAsyncTransport.ts don't appear to be correct.

TS2322: Type
typeof import("/Users/{name}/IdeaProjects/pop/node_modules/react-native-fs/index")
is not assignable to type RNFS | EXPOFS
Type
typeof import("/Users/{name}/IdeaProjects/pop/node_modules/react-native-fs/index")
is missing the following properties from type RNFS: documentDirectory, writeAsStringAsync

I think having custom type definitions to enforce using a particular package won't really work as you'll constantly need to update it as the packages update. In my opinion you'd either have to import both of those packages and do typeof (if possible) or revert to any?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants