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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed fix to support configurations with isolateModules #42

Closed
GeReV opened this issue May 27, 2021 · 1 comment
Closed

Proposed fix to support configurations with isolateModules #42

GeReV opened this issue May 27, 2021 · 1 comment

Comments

@GeReV
Copy link

GeReV commented May 27, 2021

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.

@alessandro-bottamedi
Copy link
Collaborator

Fixed in v 4.0.0 thanks

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