Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
chore: fix resolve + types for requestIdleCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Apr 5, 2021
1 parent 20a1e06 commit 65a5fd5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CompositeDisposable } from 'atom';
import { CompositeDisposable, TextEditor } from 'atom';
import path from 'path';
import { promises } from 'fs';
const { stat } = promises;
Expand All @@ -18,7 +18,7 @@ function waitOnIdle() {
return new Promise((resolve) => {
const callbackID = window.requestIdleCallback(() => {
idleCallbacks.delete(callbackID);
resolve();
resolve(true);
});
idleCallbacks.add(callbackID);
});
Expand Down Expand Up @@ -138,7 +138,7 @@ const TsLintPackage = {
grammarScopes,
scope: 'file',
lintsOnChange: true,
lint: async (textEditor) => {
lint: async (textEditor: TextEditor) => {
if (this.ignoreTypings && textEditor.getPath().toLowerCase().endsWith('.d.ts')) {
return [];
}
Expand Down
20 changes: 20 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// windows requestIdleCallback types
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export type RequestIdleCallbackHandle = any
type RequestIdleCallbackOptions = {
timeout: number
}
type RequestIdleCallbackDeadline = {
readonly didTimeout: boolean
timeRemaining: () => number
}

declare global {
interface Window {
requestIdleCallback: (
callback: (deadline: RequestIdleCallbackDeadline) => void,
opts?: RequestIdleCallbackOptions,
) => RequestIdleCallbackHandle
cancelIdleCallback: (handle: RequestIdleCallbackHandle) => void
}
}

0 comments on commit 65a5fd5

Please sign in to comment.