mowispace/react-native-logs

Proposed fix to support configurations with isolateModules

Closed this issue ยท 1 comments

GeReV commented

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch react-native-logs@3.0.3 for the project I'm working on.

Running tsc on my project resulted in the following errors:

node_modules/react-native-logs/src/index.ts:465:3 - error TS1205: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.

465   transportFunctionType,
      ~~~~~~~~~~~~~~~~~~~~~

node_modules/react-native-logs/src/index.ts:466:3 - error TS1205: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.

466   configLoggerType,
      ~~~~~~~~~~~~~~~~


Found 2 errors.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

For whatever reason, tsc decided to still run its checks on the react-native-logs/src folder, despite node_modules being excluded in tsconfig.json and despite any changes I made to try and get it to ignore it.

From what I gather, the two solutions were to either enable skipLibCheck (which didn't seem to help) or turning off isolateModules (which I would rather avoid).

I eventually settled on patch-package with the following patch which seems to solve my problem:

diff --git a/node_modules/react-native-logs/src/index.ts b/node_modules/react-native-logs/src/index.ts
index 59327a4..ddfde88 100644
--- a/node_modules/react-native-logs/src/index.ts
+++ b/node_modules/react-native-logs/src/index.ts
@@ -45,7 +45,7 @@ try {
 }
 
 /** Types Declaration */
-type transportFunctionType = (props: {
+export type transportFunctionType = (props: {
   msg: any;
   rawMsg: any;
   level: { severity: number; text: string };
@@ -60,7 +60,7 @@ type logMethodType = (
 ) => boolean;
 type levelLogMethodType = (...msgs: any[]) => boolean;
 type extendedLogType = { [key: string]: levelLogMethodType | any };
-type configLoggerType = {
+export type configLoggerType = {
   severity?: string;
   transport?: transportFunctionType;
   transportOptions?: any;
@@ -462,8 +462,6 @@ const logger = { createLogger };
 
 export {
   logger,
-  transportFunctionType,
-  configLoggerType,
   consoleTransport,
   fileAsyncTransport,
   sentryTransport,

I don't know if there are any hidden implications to this change (maybe specific TS version incompatibility?), so I'd love to know if there are.
But feel free to reject this suggestion if that is the case.

This issue body was partially generated by patch-package.

Fixed in v 4.0.0 thanks