Skip to content

Commit dfca5a1

Browse files
committed
make each return value optional for hook.Add overload
1 parent 934cba5 commit dfca5a1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

custom/plugins/hook-add.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import path from 'path';
44
import fs from 'fs';
55

66
export default function plugin(writer: GluaApiWriter, func: Function) {
7-
// let hookAnnotations = '---@overload fun(eventName: "Move", identifier: any, func: fun(ply: Player, mv: CMoveData): boolean?)\n';
87
let hookAnnotations = '';
98

109
// Iterate writer.outputDirectory to find all hooks in gm/ that have type "hook"
@@ -45,15 +44,15 @@ export default function plugin(writer: GluaApiWriter, func: Function) {
4544
if (fileJson.returns) {
4645
for (const ret of fileJson.returns) {
4746
const retType = GluaApiWriter.transformType(ret.type);
48-
returns += `${retType}, `;
47+
returns += `${retType}?, `;
4948
}
5049

5150
// Remove the last comma and space
5251
returns = returns.slice(0, -2);
5352

5453
if (returns !== '') {
5554
// We force the return type to be optional, since hooks should only return a value if they want to
56-
returns = `:(${returns}?)`;
55+
returns = `:(${returns})`;
5756
}
5857
}
5958

0 commit comments

Comments
 (0)