question

John Peterson avatar image
John Peterson asked

How to set up the PlayFab SdkTestingCloudScript git project?

Dear PlayFab community,

I have a question about the PlayFab SdkTestingCloudScript git repository. I’ve pulled it down, and when I point VS Code to the root of that project, it recognizes all of the files. When I load a .ts file, there’s a lot of stuff it can’t resolve, because the type definition files are in ./Scripts/typings/PlayFab instead of the root directory. How can I get that project to “see” those type definition files? Do I need to create a tsconfig.json file with some specification? Or what’s the best practices with which to get those files to be in subdirectories but visible throughout the project?

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.

1807605288 avatar image
1807605288 answered

In this case, you need only open the provided CloudScriptExample.sln in Visual Studio (I've tested with both 2015 and 2017). 2015 has a stricter typescript syntax, which I've broken a couple times, and I haven't tested it as recently, but it SHOULD still work, if maybe with a minor fix or two.

tsconfig.json is for specific other typescript editors/environments that are not Visual Studio. The reason that doesn't exist is because... I haven't done it yet. I haven't successfully set up any other editors, because I found them much harder to initially set up, and this is a sortof side project that I use for my own purposes. It's public because it's useful, but it's not an "Official Sdk".

For your purposes, yes, you should either add the referencepath line above to each *.ts file, or set up your environment in a way that is appropriate for your editor.

10 |1200

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

John Peterson avatar image
John Peterson answered

I was able to work around this by adding the following line to the .ts files:

/// <referencepath="Scripts/typings/PlayFab/CloudScript.d.ts"/>

But, I wondered if there was some way to have the .ts files "automatically" look for missing references in a specific directory location?

10 |1200

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

Ethan K. G avatar image
Ethan K. G answered

This tsconfig.json works fine with WebStorm:

{
  "compilerOptions": {
    "target": "es2015",
    "jsx": "react",
    "noImplicitAny": false,
    "removeComments": false,
    "noEmitOnError": true,
    "sourceMap": false,
    "outFile": "output.js"
  },
  "files": [
    "YourFile.ts",
    "Scripts/typings/PlayFab/CloudScript.d.ts",
    "Scripts/typings/PlayFab/PlayStream.d.ts",
  ],
  "exclude": [
    "node_modules"
  ]
}
10 |1200

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

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.