Commit 9171b4db authored by Robert Knight's avatar Robert Knight

Include all .d.ts files in src/types/ in main tsconfig.json

 - Include all src/types/*.d.ts files when typechecking with the main
   tsconfig.json config. Previously some of these were only included
   when using tsconfig.no-any.json.

 - Update our custom types for lodash.debounce to support arguments.
   This is needed by some of the `Thread*` components. I added the
   `leading` and `trailing` options for completeness, though we don't
   use them anywhere.

 - Add missing types in debounced callbacks in ThreadCard. These are now
   required due to the previous change.
parent 33d011b1
......@@ -25,14 +25,18 @@ import Thread from './Thread';
*/
function ThreadCard({ frameSync, thread }) {
const store = useStoreProxy();
const threadTag = thread.annotation && thread.annotation.$tag;
const threadTag = thread.annotation?.$tag ?? null;
const isFocused = threadTag && store.isAnnotationFocused(threadTag);
const focusThreadAnnotation = useMemo(
() =>
debounce(tag => {
debounce(
/** @param {string|null} tag */
tag => {
const focusTags = tag ? [tag] : [];
frameSync.focusAnnotations(focusTags);
}, 10),
},
10
),
[frameSync]
);
......
......@@ -24,7 +24,7 @@
// code for the browser.
"types": []
},
"include": ["**/*.js", "types/process.d.ts"],
"include": ["**/*.js", "types/*.d.ts"],
"exclude": [
// Tests are not checked.
"**/test/**/*.js",
......
// Self-contained types for lodash.debounce that include only the functionality
// we use and avoids adding types for the whole of lodash to our dependencies.
declare module 'lodash.debounce' {
interface DebouncedFunction {
(): void;
interface DebouncedFunction<Args extends unknown[]> {
(...args: Args): void;
cancel(): void;
flush(): void;
}
interface DebounceOptions {
leading?: boolean;
maxWait?: number;
trailing?: boolean;
}
export default function debounce(
callback: () => void,
export default function debounce<Args extends unknown[]>(
callback: (...args: Args) => void,
options?: DebounceOptions
): DebouncedFunction;
): DebouncedFunction<Args>;
export default function debounce(
callback: () => void,
delay: number
): DebouncedFunction;
export default function debounce<Args extends unknown[]>(
callback: (...args: Args) => void,
delay: number,
options?: DebounceOptions
): DebouncedFunction<Args>;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment