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
- Delete the
types
folder. Goodbye 👋 - In your
tsconfig.json
, add thisinclude
array:
You might have to adjust the relative path to node_modules according to your project structure.{ "include": [ "src/**/*", "../../node_modules/@csmodding/urbandevkit/cs2-types" ], "compilerOptions": { // ... } }
- 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:
- Run
npx create-csii-ui-mod update
- Retrieve a copy here: https://github.com/CitiesSkylinesModding/StockModTemplatesDiffer/tree/main/ui/types