---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/typescript.md
  - https://yandex.com/dev/games/doc/hi/sdk/typescript.md
  - https://yandex.com/dev/games/doc/ko/sdk/typescript.md
  - https://yandex.com/dev/games/doc/ru/sdk/typescript.md
  - https://yandex.com/dev/games/doc/tr/sdk/typescript.md
  - https://yandex.com/dev/games/doc/vi/sdk/typescript.md
  - https://yandex.com/dev/games/doc/zh/sdk/typescript.md
  - href: vi/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.com/dev/games/doc/vi/llms.txt

# TypeScript

Để thêm SDK vào trò chơi được phát triển trên TypeScript:

1. Cài đặt `npm`, theo hướng dẫn trên trang [Node.JS](https://nodejs.org/en/).
1. Để định kiểu SDK, hãy cài đặt gói [@types/ysdk](https://www.npmjs.com/package/@types/ysdk):

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

1. Nhập các kiểu module SDK cần thiết vào các tập tin dự án. Ví dụ, nhập kiểu `ysdk` và `player` có thể thực hiện như sau:

    ```typescript
    // Nhập các kiểu module SDK cần thiết.
    import type { SDK, Player } from '@types/ysdk';

    ...

    // Ví dụ sử dụng SDK với định kiểu.
    const ysdk: SDK = await YaGames.init();
    const player: Player = await ysdk.getPlayer();
    ```

---


<a href="https://www.npmjs.com/package/@types/ysdk">
  <span class="button">Kho lưu trữ</span>
</a>
