TypeScript `globalThis.SDK` not defined yet?

0 favourites
  • 5 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Hi, everybody.

    I'm new with Construct 3.

    I'm trying to develop a plugin using TypeScript.

    I've already added TypeScript support following this guide but something seems to be missing.

    Within the 3 files `instance.ts`, `plugin.ts` and `type.ts` the `globalThis.SDK` object is referenced quite a lot but is not defined anywhere.

    Am I doing something wrong?

    How can I solve this issue?

    Thanks.

  • It is defined in the editor-provided TypeScript definition files. The 'singleglobal' SDK sample works for me, being fully validated in 'watch' mode in VS Code.

    Make sure you're using the addon SDK v2, and that you followed all the steps correctly.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Mmmh... Ok, strange!

    I started by cloning this repository.

    Then, I enabled "Developer Mode" in Construct and selected "Set up TypeScript for Addon". After a while, a popup informed me that exactly 96 files had been generated inside my project directory.

    I installed TypeScript with NPM and tried to compile the project.

    These are the errors I've got:

    > Dinostruct 

    Pluginszb@1.0.0 typecheck /home/matteo/projects/dinostruct-plugin

    tsc

    instance.ts(2,24): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

    instance.ts(8,23): error TS2503: Cannot find namespace 'SDK'.

    instance.ts(8,44): error TS2503: Cannot find namespace 'SDK'.

    instance.ts(21,39): error TS2304: Cannot find name 'EditorPropertyValueType'.

    plugin.ts(2,24): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

    plugin.ts(25,33): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

    plugin.ts(26,40): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

    plugin.ts(29,36): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

    type.ts(2,24): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.

    type.ts(8,25): error TS2503: Cannot find namespace 'SDK'.

    type.ts(8,55): error TS2503: Cannot find namespace 'SDK'.

     ELIFECYCLE  Command failed with exit code 2.

    ---

    I read the type definition files and I wasn't able to find a SDK namespace.

    I discovered -in fact- a C3 namespace (defined in the ts-defs/runtime/AddonSDK.d.ts file), used within some files like c3runtime/actions.ts, c3runtime/conditions.ts, c3runtime/expressions.ts and so on... But no SDK.

    I also searched for some of the classes mentioned and used within the 3 files that throw errors like SDK.IInstanceBase or SDK.IPluginBase but I wasn't able to find those either.

    Instead, I discovered some similar classes: ISDKInstanceBase & ISDKPluginBase; but then I realized that they are already used in the c3runtime/instance.ts and c3runtime/plugin.ts files.

    I also couldn't find any similar reference to EditorPropertyValueType used in the instance.ts file on line 21.

    ---

    Of course I know I'm doing something wrong but I can't figure out what is it.

    What's the problem? What am I doing wrong?

    Thanks.

  • Actually, when I try to use 'Set up TypeScript' it reports an error for me. I think something might have been broken recently - I'll see if I can fix it for the next release.

  • Try again with r399 - does it work now? It fixes a bug where it wasn't setting up TypeScript for addons properly.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)