jitsi / jitsi-meet

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
https://jitsi.org/meet
Apache License 2.0
22.07k stars 6.58k forks source link

[RNSDK] Compile Typescript to Javascript before deploying #14718

Open danilvalov opened 2 months ago

danilvalov commented 2 months ago

Description:

Jitsi React Native SDK contains a Typescript-only version of the package (there are Typescript files instead of Javascript files): npmjs/@jitsi/react-native-sdk#codeTab

Maybe a better solution would be to compile TS to JS when new version releasing? I know people who doesn't use Typescript, they use Javascript inside their React Native projects

Also when I run a type checking process using tsc --noEmit command in my project I see many errors from node_modules/@jitsi/react-native/sdk:

# tsc --noEmit
node_modules/@jitsi/react-native-sdk/index.tsx:16:33 - error TS2307: Cannot find module '../react/features/breakout-rooms/types' or its corresponding type declarations.

16 import type { IRoomsInfo } from '../react/features/breakout-rooms/types';
                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@jitsi/react-native-sdk/index.tsx:82:30 - error TS2531: Object is possibly 'null'.

82             const dispatch = app.current.state.store.dispatch;
                                ~~~~~~~~~~~

node_modules/@jitsi/react-native-sdk/index.tsx:87:30 - error TS2531: Object is possibly 'null'.

87             const dispatch = app.current.state.store.dispatch;
                                ~~~~~~~~~~~
...

Found 624 errors in 227 files.

It happens because Typescript (inside my project) imports the Jitsi RN SDK package as part of its own code rather than detecting it as an external package (because when we use import ... from '@jitsi/react-native-sdk' we import a index.tsx file instead of a index.js file which does not exist).

saghul commented 1 month ago

Maybe a better solution would be to compile TS to JS when new version releasing?

Interesting request. I'll be honest, nobody has asked yet, so I'm hesitant to make any changes until we receive more feedback.

Also when I run a type checking process using tsc --noEmit command in my project I see many errors from node_modules/@jitsi/react-native/sdk:

I think our SDK should ship with the tsconfig file we use (tsconfig.native.json at the root folder) and that would be solved.

danilvalov commented 1 month ago

Interesting request. I'll be honest, nobody has asked yet, so I'm hesitant to make any changes until we receive more feedback.

Maybe you're right. But this is the first time I've seen a library that doesn't compile Typescript into Javascript before release. In particular, this is due to the fact that the Typescript versions may not match within the project and within the library, which will lead to problems. More often I see compiled files into Javascript and separately files of Typescript types (*.d.ts, declaration option in tsconfig.json).

Also, as I know, it is impossible in Typescript when compiling to set separate compilation rules for a separate directory (this is not ifint or gitignor), as a result, all developers will have to forcefully change the compilation rules on their projects to the compilation rules of this library, which is strange and often impossible.

saghul commented 1 month ago

I don't think we have special rules in our sample app though, it's a standard TS RN app.