Proper typechecking for decorators
This commit is contained in:
parent
ab68a5ffc6
commit
87837754f6
|
|
@ -14,8 +14,12 @@ export abstract class RPGComponentBase implements RPGComponent {
|
|||
const vars: RPGVariables = {};
|
||||
for (const [methodKey, exportName] of keys) {
|
||||
const k = String(methodKey);
|
||||
const v = (this as unknown as Record<string, RPGVariables[string]>)[k];
|
||||
if (v != null) {
|
||||
const v = (this as Record<string, unknown>)[k];
|
||||
if (
|
||||
typeof v === 'number'
|
||||
|| typeof v === 'string'
|
||||
|| typeof v === 'boolean'
|
||||
) {
|
||||
vars[exportName] = v;
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +33,10 @@ export abstract class RPGComponentBase implements RPGComponent {
|
|||
const actions: RPGActions = {};
|
||||
for (const key of keys) {
|
||||
const k = String(key);
|
||||
actions[k] = (arg?: unknown) => (this as unknown as Record<string, (a?: unknown) => unknown>)[k](arg);
|
||||
const fn = (this as Record<string, unknown>)[k];
|
||||
if (typeof fn === 'function') {
|
||||
actions[k] = fn.bind(this);
|
||||
}
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue