Skip to content

CS2 UI Types as a Dependency

Morgan Touverey Quilling edited this page Jul 14, 2024 · 5 revisions

Created by: @toverux
Authors: @toverux
SDKs needed: UI (npm)

Overview

If you're like me, you don't like to have third-party code lying around in your codebase, you might be slightly triggered by the fact that cs2/*'s .d.ts files are part of your mod codebase.

UrbanDevKit conveniently bundles this folder, untouched, in its npm distribution, allowing you to import it and upgrade type definitions by upgrading the package.

Setup

  1. Delete the types folder. Goodbye 👋
  2. In your tsconfig.json, add this include array:
    {
      "include": [
        "src/**/*",
        "../../node_modules/@csmodding/urbandevkit/cs2-types"
      ],
      "compilerOptions": {
        // ...
      }
    }
    You might have to adjust the relative path to node_modules according to your project structure.
  3. Try to compile your UI mod, you should be good!

Un-Setup

If at any point, you wanna go back and retrieve an up-to-date version of the types folder, you can:

Features & Helpers

.NET-only Features

  • Shared State Share state between assemblies without linking
  • Coroutine Runner Helper to start coroutines from anywhere or wrap them into Tasks.

UI-only Features

.NET+UI Features

Contributing

Clone this wiki locally