Civ VI TypeScript Types
raw JSON → 1.0.11 verified Fri May 01 auth: no javascript
TypeScript declaration files for modding Civilization VI using the TypeScriptToLua transpiler. Version 1.0.11 provides type definitions for the Civ6 modding API, enabling type-safe Lua development with TypeScript. Released irregularly via npm. Key differentiator: bridges TypeScript to Lua for Civ6 modding, leveraging TSTL ecosystem. No stable release cadence; latest version as of early 2025 is 1.0.11.
Common errors
error Cannot find name 'Player'. ↓
cause Missing 'civvi-types' in tsconfig types array.
fix
Add "civvi-types" to compilerOptions.types in tsconfig.json.
error TypeError: object.method is not a function ↓
cause Using dot notation instead of colon for Lua method calls.
fix
Replace '.' with ':' for method calls: object:method() instead of object.method().
error Cannot find module 'civvi-types' or its corresponding type declarations. ↓
cause Attempting to import civvi-types instead of adding to types array.
fix
Remove import statement; civvi-types is a global type package, not a module.
Warnings
gotcha Types are global; do not import from 'civvi-types' directly. ↓
fix Do not use import statements. Add 'civvi-types' to the 'types' array in tsconfig.json.
gotcha All Civ6 API functions use Lua-style colon syntax (method calls with ':' instead of '.'). Forgetting this causes runtime errors. ↓
fix Use ':' for method calls: object:method() not object.method().
deprecated Old versions (pre-1.0.0) used different package name or import patterns. ↓
fix Upgrade to 1.0.11 and follow new tsconfig pattern.
gotcha Requires TSTL (TypeScriptToLua) to transpile to Lua. Pacakge alone does not produce runnable mods. ↓
fix Install typescript, typescript-to-lua, lua-types, and @typescript-to-lua/language-extensions.
gotcha The 'types' array must include lua-types and language-extensions in the correct order for type resolution. ↓
fix Add exactly: 'lua-types/core/coroutine', 'lua-types/core/global', 'lua-types/core/math', 'lua-types/core/metatable', 'lua-types/core/string', 'lua-types/core/table', '@typescript-to-lua/language-extensions', 'civvi-types'.
Install
npm install civvi-types yarn add civvi-types pnpm add civvi-types Imports
- Civ6 API types (global) wrong
import { something } from 'civvi-types'correctAdd 'civvi-types' to 'types' array in tsconfig.json - LuaTable wrong
import { LuaTable } from 'civvi-types'correctProvided by @typescript-to-lua/language-extensions - Player wrong
const Player = require('civvi-types').PlayercorrectUse Player directly as global type (no import)
Quickstart
// tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"lib": ["ES2022.Array", "ES2022.Error", "ES2022.Object", "ES2022.String", "ES2015.Promise", "ES5", "ES2015.Iterable"],
"moduleResolution": "node",
"types": ["lua-types/core/coroutine", "lua-types/core/global", "lua-types/core/math", "lua-types/core/metatable", "lua-types/core/string", "lua-types/core/table", "@typescript-to-lua/language-extensions", "civvi-types"],
"strict": true
},
"tstl": {
"luaTarget": "5.1",
"luaLibImport": "inline",
"noImplicitGlobalVariables": true,
"noImplicitSelf": true
}
}
// Example mod file: ModMain.ts
const pPlayer = Players[0]; // Player type inferred from civvi-types
const cap = pPlayer:GetCapitalCity(); // Uses Lua-style method call
print(cap:GetName()); // Type-safe print