Describe the bug
The joinChannel method in the IAgoraRtcEngine interface expects the uid parameter to be a number, but the TypeScript definition allows it to be a string. This inconsistency leads to a -2 error (invalid parameter) when a string UID is provided, even though the type definition suggests it should be valid.
To Reproduce
Steps to reproduce the behavior:
Initialize the Agora RTC engine
Attempt to join a channel using a string UID
Observe that the joinChannel method returns -2 (invalid parameter)
Expected behavior
The joinChannel method should either:
Accept both number and string types for the uid parameter, as implied by the current TypeScript definition, or
The TypeScript definition should be updated to only allow number types for the uid parameter to match the actual implementation.
Code example
import RtcEngine from 'react-native-agora';
// ...
const joinChannel = async () => {
if (engine && roomID && token) {
try {
// This causes a -2 error, even though the type definition allows string
const result = await engine.joinChannel(token, roomID, "user123", null);
console.log('Join channel result:', result);
} catch (error) {
console.error('Failed to join channel:', error);
}
}
};
Environment:
react-native-agora version: [e.g., 4.2.1]
React Native version: [e.g., 0.71.8]
Device: [e.g., iPhone 12]
OS: [e.g., iOS 16.5]
Additional context
The TypeScript definition in node_modules/react-native-agora/src/IAgoraRtcEngine.ts shows:
abstract joinChannel(
token: string,
channelId: string,
uid: number | string, // Note: allows both number and string
options: ChannelMediaOptions
): number;
However, the actual implementation only accepts a number for the uid parameter. This discrepancy between the type definition and the implementation is causing confusion and potential runtime errors.
Proposed solution
Either update the implementation to accept both number and string types for uid, or update the TypeScript definition to only allow number types. This will ensure consistency between the type definition and the actual behavior of the method.
Describe the bug The
joinChannel
method in theIAgoraRtcEngine
interface expects theuid
parameter to be a number, but the TypeScript definition allows it to be a string. This inconsistency leads to a-2
error (invalid parameter) when a string UID is provided, even though the type definition suggests it should be valid.To Reproduce Steps to reproduce the behavior:
joinChannel
method returns-2
(invalid parameter)Expected behavior The
joinChannel
method should either:uid
parameter, as implied by the current TypeScript definition, oruid
parameter to match the actual implementation.Code example
Environment:
Additional context The TypeScript definition in
node_modules/react-native-agora/src/IAgoraRtcEngine.ts
shows:However, the actual implementation only accepts a number for the
uid
parameter. This discrepancy between the type definition and the implementation is causing confusion and potential runtime errors.Proposed solution Either update the implementation to accept both number and string types for
uid
, or update the TypeScript definition to only allow number types. This will ensure consistency between the type definition and the actual behavior of the method.