Skip to content

Commit eaaa622

Browse files
committed
Improve typing of resolveFunction
1 parent 75aa44b commit eaaa622

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/codeql.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@ export function setCodeQL(codeql: Partial<CodeQL>): void {
391391
cachedCodeQL = createStubCodeQL(codeql);
392392
}
393393

394-
function resolveFunction<T>(
394+
function resolveFunction<K extends keyof CodeQL, T extends CodeQL[K]>(
395395
partialCodeql: Partial<CodeQL>,
396-
methodName: string,
396+
methodName: K,
397397
defaultImplementation?: T,
398398
): T {
399399
if (typeof partialCodeql[methodName] !== "function") {
@@ -403,7 +403,7 @@ function resolveFunction<T>(
403403
const dummyMethod = () => {
404404
throw new Error(`CodeQL ${methodName} method not correctly defined`);
405405
};
406-
return dummyMethod as T;
406+
return dummyMethod as unknown as T;
407407
}
408408
return partialCodeql[methodName] as T;
409409
}

0 commit comments

Comments
 (0)