question

josephtorbett avatar image
josephtorbett asked

How can I use the Playfab API while writing a Cloud Script with TypeScript?

I'm trying to get a handle on writing Cloud Script code in Visual Studio using TypeScript, but I have no idea how to actually use Playfabs API / SDK in this development environment.

I'm sure it's something simple, but I can't seem to figure it out.

Any help in getting this figured out is greatly appreciated!

apissdksCloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Joshua Strunk avatar image
Joshua Strunk answered

Just in case you haven't, have you looked at the example repo https://github.com/PlayFab/SdkTestingCloudScript for VS TypeScript Cloud Script integration? There is also this blog post which goes over it for VSCode https://blog.playfab.com/blog/typescript2

If you have looked at those could you post more details on what is confusing you or giving you trouble.(unfortunately I am more familiar with compiling TypeScript from command line and editing it with VSCode, but can try and help)

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

josephtorbett avatar image josephtorbett commented ·

Well I'm just trying to get the Playfab API to be in the type predictions while using TypeScript!

I have everything else but that going fine!

1 Like 1 ·
Joshua Strunk avatar image Joshua Strunk josephtorbett commented ·

You need to be sure the .d.ts files found at https://github.com/PlayFab/SdkTestingCloudScript/tree/master/Scripts/typings/PlayFab is contained in the files marked for inclusion in your tsconfig.json file. You may also need to ensure you have compilerOptions.outFile set as well.

I have also noticed that some IDEs will only intellisense on open files. If that is the case you might need to open the CloudScript.d.ts file in a tab which you will have to leave open while working on your project. If you need to also explicitly type something to a server api model you should be able to access them by through the namespace`PlayFabServerModels.`.

2 Likes 2 ·
josephtorbett avatar image josephtorbett Joshua Strunk commented ·

Ahhhh okay okay This is the type of thing I thought I was missing!

Thanks!!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.