Using Typescript declaration files

How can i use declaration files in my Project with Cocos Creator 3.0.

I have tried adding Nakama Api declaration file to use Nakama types in my project , but, when i run the game i get error : for example the declaration file name assets/nakama/client.d.ts , i get error Failed to load resource assets/nakama/client.js

how can i compile those declaration files to get the js format of them in runtime ?

Declaration files only provide types information, you need the responding code file aka .js.

I don’t know more about Nakama but seems you need to grab nakama-js.esm.js into assets directory.

Then you can access nakama through import syntax like Nakama’s readme states:

import { Client } from '<path-to-nakama-js.esm.js-relative-from-current-file>';
new Client(/* ... */)

using this solution will only run the code without issues , What i want is taking benefits from using types Hint while writing code , is that possible with CC3.0 using typescript declaration files ?

Rename the declaration file as nakema-js.esm.d.ts

1 Like

Thank’s a lot :ok_hand:
that’s exactly what i want to achieve .

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.