---
metadata:
  - name: generator
    content: Diplodoc Platform v5.55.2
alternate:
  - https://yandex.ru/dev/games/doc/en/sdk/typescript.md
  - https://yandex.ru/dev/games/doc/hi/sdk/typescript.md
  - https://yandex.ru/dev/games/doc/ko/sdk/typescript.md
  - https://yandex.ru/dev/games/doc/ru/sdk/typescript.md
  - https://yandex.ru/dev/games/doc/tr/sdk/typescript.md
  - https://yandex.ru/dev/games/doc/vi/sdk/typescript.md
  - https://yandex.ru/dev/games/doc/zh/sdk/typescript.md
  - href: ru/sdk/typescript.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/games/doc/ru/llms.txt

# TypeScript

<!-- source: ru/_includes/script-common.md -->
<!-- source: ru/_includes/script/index-js.md -->

<!-- endsource: ru/_includes/script/index-js.md -->

<!-- source: ru/_includes/script/requirements-js.md -->

<!-- endsource: ru/_includes/script/requirements-js.md -->

<!-- source: ru/_includes/script/image-modal-js.md -->

<!-- endsource: ru/_includes/script/image-modal-js.md -->
<!-- endsource: ru/_includes/script-common.md -->

Чтобы добавить SDK в игру, разработанную на TypeScript:

1. Установите `npm`, следуя инструкциям на сайте [Node.JS](https://nodejs.org/en/){.external}.
1. Для типизации SDK установите пакет [@types/ysdk](https://www.npmjs.com/package/@types/ysdk){.external}:

    ```console
    npm install --save @types/ysdk
    ```

1. Импортируйте в файлы проекта требуемые типы модулей SDK. Например, импортировать типы `ysdk` и `player` можно так:

    ```typescript showLineNumbers
    // Импорт необходимых типов модулей SDK.
    import type { SDK, Player } from 'ysdk';

    ...

    // Пример использования SDK с типизацией.
    const ysdk: SDK = await YaGames.init();
    const player: Player = await ysdk.getPlayer();
    ```

---


<!-- source: ru/_includes/plugin-tg-support.md -->
{% note info %}

Если при работе с плагином вы столкнулись с проблемой или у вас появился вопрос, обратитесь в [сообщество в Телеграме](https://t.me/yagamedev){.telegram} или в [сообщество ВКонтакте](https://vk.ru/yandexgmsdev){.vk}.

{% endnote %}
<!-- endsource: ru/_includes/plugin-tg-support.md -->


<a href="https://www.npmjs.com/package/@types/ysdk">
  <span class="button">Репозиторий</span>
</a>
