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

[RNSDK] Compile Typescript to Javascript before deploying #14718

Open
danilvalov opened this issue May 6, 2024 · 3 comments
Open

[RNSDK] Compile Typescript to Javascript before deploying #14718

danilvalov opened this issue May 6, 2024 · 3 comments

Comments

@danilvalov
Copy link

danilvalov commented May 6, 2024

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
Copy link
Member

saghul commented May 7, 2024

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
Copy link
Author

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
Copy link
Member

saghul commented May 7, 2024

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

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