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

Commit 65a5fd5

Browse files
committed
chore: fix resolve + types for requestIdleCallback
1 parent 20a1e06 commit 65a5fd5

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

lib/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CompositeDisposable } from 'atom';
1+
import { CompositeDisposable, TextEditor } from 'atom';
22
import path from 'path';
33
import { promises } from 'fs';
44
const { stat } = promises;
@@ -18,7 +18,7 @@ function waitOnIdle() {
1818
return new Promise((resolve) => {
1919
const callbackID = window.requestIdleCallback(() => {
2020
idleCallbacks.delete(callbackID);
21-
resolve();
21+
resolve(true);
2222
});
2323
idleCallbacks.add(callbackID);
2424
});
@@ -138,7 +138,7 @@ const TsLintPackage = {
138138
grammarScopes,
139139
scope: 'file',
140140
lintsOnChange: true,
141-
lint: async (textEditor) => {
141+
lint: async (textEditor: TextEditor) => {
142142
if (this.ignoreTypings && textEditor.getPath().toLowerCase().endsWith('.d.ts')) {
143143
return [];
144144
}

lib/types.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// windows requestIdleCallback types
2+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3+
export type RequestIdleCallbackHandle = any
4+
type RequestIdleCallbackOptions = {
5+
timeout: number
6+
}
7+
type RequestIdleCallbackDeadline = {
8+
readonly didTimeout: boolean
9+
timeRemaining: () => number
10+
}
11+
12+
declare global {
13+
interface Window {
14+
requestIdleCallback: (
15+
callback: (deadline: RequestIdleCallbackDeadline) => void,
16+
opts?: RequestIdleCallbackOptions,
17+
) => RequestIdleCallbackHandle
18+
cancelIdleCallback: (handle: RequestIdleCallbackHandle) => void
19+
}
20+
}

0 commit comments

Comments
 (0)