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'; ...@@ -25,14 +25,18 @@ import Thread from './Thread';
*/ */
function ThreadCard({ frameSync, thread }) { function ThreadCard({ frameSync, thread }) {
const store = useStoreProxy(); const store = useStoreProxy();
const threadTag = thread.annotation && thread.annotation.$tag; const threadTag = thread.annotation?.$tag ?? null;
const isFocused = threadTag && store.isAnnotationFocused(threadTag); const isFocused = threadTag && store.isAnnotationFocused(threadTag);
const focusThreadAnnotation = useMemo( const focusThreadAnnotation = useMemo(
() => () =>
debounce(tag => { debounce(
const focusTags = tag ? [tag] : []; /** @param {string|null} tag */
frameSync.focusAnnotations(focusTags); tag => {
}, 10), const focusTags = tag ? [tag] : [];
frameSync.focusAnnotations(focusTags);
},
10
),
[frameSync] [frameSync]
); );
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
// code for the browser. // code for the browser.
"types": [] "types": []
}, },
"include": ["**/*.js", "types/process.d.ts"], "include": ["**/*.js", "types/*.d.ts"],
"exclude": [ "exclude": [
// Tests are not checked. // Tests are not checked.
"**/test/**/*.js", "**/test/**/*.js",
......
// Self-contained types for lodash.debounce that include only the functionality // 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. // we use and avoids adding types for the whole of lodash to our dependencies.
declare module 'lodash.debounce' { declare module 'lodash.debounce' {
interface DebouncedFunction { interface DebouncedFunction<Args extends unknown[]> {
(): void; (...args: Args): void;
cancel(): void; cancel(): void;
flush(): void; flush(): void;
} }
interface DebounceOptions { interface DebounceOptions {
leading?: boolean;
maxWait?: number; maxWait?: number;
trailing?: boolean;
} }
export default function debounce( export default function debounce<Args extends unknown[]>(
callback: () => void, callback: (...args: Args) => void,
options?: DebounceOptions options?: DebounceOptions
): DebouncedFunction; ): DebouncedFunction<Args>;
export default function debounce( export default function debounce<Args extends unknown[]>(
callback: () => void, callback: (...args: Args) => void,
delay: number delay: number,
): DebouncedFunction; 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