I am currently facing a challenge of integrating the Microsoft Playfab Javascript Library into my React Native app following the recommendations provided here. The library comes with typings and is structured as illustrated here. In my file playfabWrapper.ts
, I have the code snippet below.
/// <reference path="../../node_modules/playfab-web-sdk/src/Typings/PlayFab/PlayfabClientApi.d.ts" />
import Playfab from 'playfab-web-sdk/src/PlayFab/PlayFabClientApi.js';
function test(titleId: string, customId: string/*, success: (data: PlayFabClientModels.LoginResult) => void, error: (message: string) => void*/): void {
Playfab.ClientApi.LoginWithCustomID({
TitleId: titleId,
CustomId: customId,
CreateAccount: true,
}, (result: any, problem: any) => {
...
});
}
Encountering the error below:
Could not find a declaration file for module 'playfab-web-sdk/src/PlayFab/PlayFabClientApi.js'. '/Users/../project/node_modules/playfab-web-sdk/src/PlayFab/PlayFabClientApi.js' implicitly has an 'any' type.
Try `npm install @types/playfab-web-sdk` if it exists or add a new declaration (.d.ts) file containing `declare module 'playfab-web-sdk/src/PlayFab/PlayFabClientApi.js';`
As a workaround, I attempted copying the typings from Typings/Playfab and pasting them in the same directory as PlayFabClientApi.js
. This action resulted in the error below.
File '/Users/../project/node_modules/playfab-web-sdk/src/PlayFab/PlayFabClientApi.d.ts' is not a module.
Interestingly, deleting the import line enables my IDE to correctly detect Playfab
, but it remains undefined. Is there a step I may have overlooked? Is this type of library even feasible to import? I noticed it lacks an index.d.ts
, could this potentially be contributing to the issue at hand? Any guidance on this matter would be greatly appreciated. Thank you.