Skip to content

Commit d1e61fe

Browse files
committed
Add lua-types
1 parent 7bc1121 commit d1e61fe

6 files changed

Lines changed: 17 additions & 13 deletions

File tree

game/scripts/declarations

game/scripts/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"rootDir": "vscripts",
44
"target": "esnext",
55
"lib": ["esnext"],
6-
"types": [],
6+
"types": ["lua-types/jit"],
77
"moduleResolution": "node",
88
"experimentalDecorators": true,
99
"strict": true

game/scripts/vscripts/addon_game_mode.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import "./lib/timers";
22
import { GameMode } from "./GameMode";
33

4-
declare function getfenv(this: void, obj: any): any;
54
Object.assign(getfenv(1), {
65
Activate: GameMode.Activate,
76
Precache: GameMode.Precache,

game/scripts/vscripts/lib/dota_ts_adapter.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
if (_G.reloadCache === undefined) {
2-
_G.reloadCache = {}
1+
const global = globalThis as typeof globalThis & { reloadCache: Record<string, any> };
2+
if (global.reloadCache === undefined) {
3+
global.reloadCache = {};
34
}
45

5-
export function reloadable<T extends {new(...args: any[]): {}}>(constructor: T): T {
6+
export function reloadable<T extends { new (...args: any[]): {} }>(constructor: T): T {
67
const className = constructor.name;
7-
if (_G.reloadCache[className] === undefined) {
8-
_G.reloadCache[className] = constructor;
8+
if (global.reloadCache[className] === undefined) {
9+
global.reloadCache[className] = constructor;
910
}
1011

11-
Object.assign(_G.reloadCache[className].prototype, constructor.prototype);
12-
return _G.reloadCache[className];
12+
Object.assign(global.reloadCache[className].prototype, constructor.prototype);
13+
return global.reloadCache[className];
1314
}
1415

15-
declare function getfenv(this: void, obj: any): {[key: string]: any};
16-
declare function getmetatable(this: void, obj: object): object;
17-
1816
export function luaModifier<T extends typeof CDOTA_Modifier_Lua>(modifier: T): T {
1917
const instance: any = {};
2018
let prototype = modifier.prototype as any;

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"devDependencies": {
1414
"find-steam-app": "^1.0.2",
15+
"lua-types": "^2.6.2",
1516
"npm-run-all": "^4.1.5",
1617
"panorama-types": "^1.0.0",
1718
"typescript": "^3.7.4",

0 commit comments

Comments
 (0)