CS2 UI Types as a Dependency - CitiesSkylinesModding/UrbanDevKit GitHub Wiki

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: