-
Notifications
You must be signed in to change notification settings - Fork 0
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)
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.
- 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!
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
- Shared State Share state between assemblies without linking
- Coroutine Runner Helper to start coroutines from anywhere or wrap them into Tasks.
-
cs2/*
Types as a Dependency Get rid of thattypes/
folder from your codebase.
- Cooperative Preloading Prevent the user to load a game while mods are preloading