Skip to content

Commit 16cd2d5

Browse files
authored
Set lualib tsconfig to strict (#1401)
1 parent 9c79d72 commit 16cd2d5

29 files changed

+2293
-1566
lines changed

package-lock.json

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

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@
5656
"@types/jest": "^27.5.2",
5757
"@types/node": "^13.7.7",
5858
"@types/resolve": "1.14.0",
59-
"@typescript-eslint/eslint-plugin": "^5.36.1",
60-
"@typescript-eslint/parser": "^5.36.1",
61-
"eslint": "^8.23.0",
62-
"eslint-plugin-import": "^2.26.0",
63-
"eslint-plugin-jest": "^26.8.7",
59+
"@typescript-eslint/eslint-plugin": "^5.52.0",
60+
"@typescript-eslint/parser": "^5.52.0",
61+
"eslint": "^8.34.0",
62+
"eslint-plugin-import": "^2.27.5",
63+
"eslint-plugin-jest": "^26.9.0",
6464
"fs-extra": "^8.1.0",
6565
"javascript-stringify": "^2.0.1",
6666
"jest": "^28.1.3",
67-
"jest-circus": "^29.0.1",
67+
"jest-circus": "^29.4.2",
6868
"lua-types": "^2.13.0",
6969
"lua-wasm-bindings": "^0.3.1",
7070
"prettier": "^2.3.2",

src/lualib/ArrayFrom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function arrayLikeStep(this: ArrayLike<unknown>, index: number): LuaMultiReturn<
1111
const arrayLikeIterator: (
1212
this: void,
1313
arr: ArrayLike<unknown> | Iterable<unknown>
14-
) => LuaIterable<LuaMultiReturn<[number, unknown]>> = (arr => {
14+
) => LuaIterable<LuaMultiReturn<[number, unknown]>> = ((arr: any) => {
1515
if (typeof arr.length === "number") return $multi(arrayLikeStep, arr, 0);
1616
return __TS__Iterator(arr);
1717
}) as any;

src/lualib/ArrayReduce.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function __TS__ArrayReduce<TElement, TAccumulator>(
99
const len = this.length;
1010

1111
let k = 0;
12-
let accumulator: TAccumulator = undefined;
12+
let accumulator: TAccumulator = undefined!;
1313

1414
// Check if initial value is present in function call
1515
if (__TS__CountVarargs(...initial) !== 0) {

src/lualib/ArrayReduceRight.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function __TS__ArrayReduceRight<TElement, TAccumulator>(
99
const len = this.length;
1010

1111
let k = len - 1;
12-
let accumulator: TAccumulator = undefined;
12+
let accumulator: TAccumulator = undefined!;
1313

1414
// Check if initial value is present in function call
1515
if (__TS__CountVarargs(...initial) !== 0) {

src/lualib/ArraySetLength.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function __TS__ArraySetLength<T>(this: T[], length: number): number {
99
throw `invalid array length: ${length}`;
1010
}
1111
for (const i of $range(length + 1, this.length)) {
12-
this[i - 1] = undefined;
12+
this[i - 1] = undefined!;
1313
}
1414
return length;
1515
}

src/lualib/ArraySplice.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ export function __TS__ArraySplice<T>(this: T[], ...args: any[]): T[] {
5858
if (this[from - 1]) {
5959
this[to - 1] = this[from - 1];
6060
} else {
61-
this[to - 1] = undefined;
61+
this[to - 1] = undefined!;
6262
}
6363
}
6464
for (const k of $range(len - actualDeleteCount + itemCount + 1, len)) {
65-
this[k - 1] = undefined;
65+
this[k - 1] = undefined!;
6666
}
6767
} else if (itemCount > actualDeleteCount) {
6868
for (const k of $range(len - actualDeleteCount, start + 1, -1)) {
@@ -72,7 +72,7 @@ export function __TS__ArraySplice<T>(this: T[], ...args: any[]): T[] {
7272
if (this[from - 1]) {
7373
this[to - 1] = this[from - 1];
7474
} else {
75-
this[to - 1] = undefined;
75+
this[to - 1] = undefined!;
7676
}
7777
}
7878
}
@@ -84,7 +84,7 @@ export function __TS__ArraySplice<T>(this: T[], ...args: any[]): T[] {
8484
}
8585

8686
for (const k of $range(this.length, len - actualDeleteCount + itemCount + 1, -1)) {
87-
this[k - 1] = undefined;
87+
this[k - 1] = undefined!;
8888
}
8989

9090
return out;

src/lualib/Decorate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ export function __TS__Decorate<TTarget extends AnyTable, TKey extends keyof TTar
1616

1717
for (let i = decorators.length; i >= 0; i--) {
1818
const decorator = decorators[i];
19-
if (decorator) {
19+
if (decorator !== undefined) {
2020
const oldResult = result;
2121

2222
if (key === undefined) {
2323
result = decorator(result);
2424
} else if (desc === true) {
2525
const value = rawget(target, key);
26-
const descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) || {
26+
const descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) ?? {
2727
configurable: true,
2828
writable: true,
2929
value,

src/lualib/DecorateParam.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Decorator } from "./Decorator";
22

33
type ParamDecorator<TTarget extends AnyTable, TKey extends keyof TTarget> = (
44
target: TTarget,
5-
key: TKey,
5+
key: TKey | undefined,
66
index: number
77
) => TTarget;
88
export function __TS__DecorateParam<TTarget extends AnyTable, TKey extends keyof TTarget>(

src/lualib/Error.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function getErrorStack(constructor: () => any): string {
2727

2828
function wrapErrorToString<T extends Error>(getDescription: (this: T) => string): (this: T) => string {
2929
return function (this: Error): string {
30-
const description = getDescription.call(this);
30+
const description = getDescription.call(this as T);
3131
const caller = debug.getinfo(3, "f");
3232
// @ts-ignore Fails when compiled with Lua 5.0 types
3333
const isClassicLua = _VERSION.includes("Lua 5.0") || _VERSION === "Lua 5.1";
@@ -54,7 +54,7 @@ export const Error: ErrorConstructor = initErrorClass(
5454
constructor(public message = "") {
5555
this.stack = getErrorStack((this.constructor as any).new);
5656
const metatable = getmetatable(this);
57-
if (!metatable.__errorToStringPatched) {
57+
if (metatable && !metatable.__errorToStringPatched) {
5858
metatable.__errorToStringPatched = true;
5959
metatable.__tostring = wrapErrorToString(metatable.__tostring);
6060
}

0 commit comments

Comments
 (0)