mirror of https://github.com/microsoft/vscode.git
debt - avoid `any` for timeout/interval (#249348)
This commit is contained in:
parent
814c210aa4
commit
2984f68510
|
@ -22,6 +22,7 @@
|
|||
"typings/vscode-globals-product.d.ts",
|
||||
"typings/vscode-globals-nls.d.ts",
|
||||
"typings/editContext.d.ts",
|
||||
"typings/base-common.d.ts",
|
||||
"vs/monaco.d.ts",
|
||||
"vs/editor/*",
|
||||
"vs/base/common/*",
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
declare global {
|
||||
|
||||
// --- idle callbacks
|
||||
|
||||
interface IdleDeadline {
|
||||
readonly didTimeout: boolean;
|
||||
timeRemaining(): number;
|
||||
|
@ -15,6 +17,15 @@ declare global {
|
|||
function requestIdleCallback(callback: (args: IdleDeadline) => void, options?: { timeout: number }): number;
|
||||
function cancelIdleCallback(handle: number): void;
|
||||
|
||||
// --- timeout / interval (available in all contexts, but different signatures in node.js vs web)
|
||||
|
||||
interface TimeoutHandle {readonly _: never; /* this is a trick that seems needed to prevent direct number assignment */}
|
||||
type Timeout = TimeoutHandle;
|
||||
function setTimeout(handler: string | Function, timeout?: number, ...arguments: any[]): Timeout;
|
||||
function clearTimeout(timeout: Timeout | undefined): void;
|
||||
|
||||
function setInterval(callback: (...args: any[]) => void, delay?: number, ...args: any[]): Timeout;
|
||||
function clearInterval(timeout: Timeout | undefined): void;
|
||||
}
|
||||
|
||||
export { }
|
||||
|
|
|
@ -12,7 +12,7 @@ import { Mimes } from '../common/mime.js';
|
|||
* dragover event for 800ms. If the drag is aborted before, the callback will not be triggered.
|
||||
*/
|
||||
export class DelayedDragHandler extends Disposable {
|
||||
private timeout: any;
|
||||
private timeout: Timeout | undefined = undefined;
|
||||
|
||||
constructor(container: HTMLElement, callback: () => void) {
|
||||
super();
|
||||
|
@ -24,7 +24,7 @@ export class DelayedDragHandler extends Disposable {
|
|||
this.timeout = setTimeout(() => {
|
||||
callback();
|
||||
|
||||
this.timeout = null;
|
||||
this.timeout = undefined;
|
||||
}, 800);
|
||||
}
|
||||
}));
|
||||
|
@ -39,7 +39,7 @@ export class DelayedDragHandler extends Disposable {
|
|||
private clearDragTimeout(): void {
|
||||
if (this.timeout) {
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = null;
|
||||
this.timeout = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -442,7 +442,7 @@ export class Sash extends Disposable {
|
|||
this._register(onTouchStart(e => this.onPointerStart(e, new GestureEventFactory(this.el)), this));
|
||||
const onTap = this._register(new DomEmitter(this.el, EventType.Tap)).event;
|
||||
|
||||
let doubleTapTimeout: any = undefined;
|
||||
let doubleTapTimeout: Timeout | undefined = undefined;
|
||||
this._register(onTap(event => {
|
||||
if (doubleTapTimeout) {
|
||||
clearTimeout(doubleTapTimeout);
|
||||
|
|
|
@ -524,7 +524,7 @@ export class Barrier {
|
|||
*/
|
||||
export class AutoOpenBarrier extends Barrier {
|
||||
|
||||
private readonly _timeout: any;
|
||||
private readonly _timeout: Timeout;
|
||||
|
||||
constructor(autoOpenTimeMs: number) {
|
||||
super();
|
||||
|
@ -931,13 +931,13 @@ export class ResourceQueue implements IDisposable {
|
|||
}
|
||||
|
||||
export class TimeoutTimer implements IDisposable {
|
||||
private _token: any;
|
||||
private _token: Timeout | undefined;
|
||||
private _isDisposed = false;
|
||||
|
||||
constructor();
|
||||
constructor(runner: () => void, timeout: number);
|
||||
constructor(runner?: () => void, timeout?: number) {
|
||||
this._token = -1;
|
||||
this._token = undefined;
|
||||
|
||||
if (typeof runner === 'function' && typeof timeout === 'number') {
|
||||
this.setIfNotSet(runner, timeout);
|
||||
|
@ -950,9 +950,9 @@ export class TimeoutTimer implements IDisposable {
|
|||
}
|
||||
|
||||
cancel(): void {
|
||||
if (this._token !== -1) {
|
||||
if (this._token !== undefined) {
|
||||
clearTimeout(this._token);
|
||||
this._token = -1;
|
||||
this._token = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -963,7 +963,7 @@ export class TimeoutTimer implements IDisposable {
|
|||
|
||||
this.cancel();
|
||||
this._token = setTimeout(() => {
|
||||
this._token = -1;
|
||||
this._token = undefined;
|
||||
runner();
|
||||
}, timeout);
|
||||
}
|
||||
|
@ -973,12 +973,12 @@ export class TimeoutTimer implements IDisposable {
|
|||
throw new BugIndicatingError(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);
|
||||
}
|
||||
|
||||
if (this._token !== -1) {
|
||||
if (this._token !== undefined) {
|
||||
// timer is already set
|
||||
return;
|
||||
}
|
||||
this._token = setTimeout(() => {
|
||||
this._token = -1;
|
||||
this._token = undefined;
|
||||
runner();
|
||||
}, timeout);
|
||||
}
|
||||
|
@ -1020,12 +1020,12 @@ export class RunOnceScheduler implements IDisposable {
|
|||
|
||||
protected runner: ((...args: unknown[]) => void) | null;
|
||||
|
||||
private timeoutToken: any;
|
||||
private timeoutToken: Timeout | undefined;
|
||||
private timeout: number;
|
||||
private timeoutHandler: () => void;
|
||||
|
||||
constructor(runner: (...args: any[]) => void, delay: number) {
|
||||
this.timeoutToken = -1;
|
||||
this.timeoutToken = undefined;
|
||||
this.runner = runner;
|
||||
this.timeout = delay;
|
||||
this.timeoutHandler = this.onTimeout.bind(this);
|
||||
|
@ -1045,7 +1045,7 @@ export class RunOnceScheduler implements IDisposable {
|
|||
cancel(): void {
|
||||
if (this.isScheduled()) {
|
||||
clearTimeout(this.timeoutToken);
|
||||
this.timeoutToken = -1;
|
||||
this.timeoutToken = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1069,7 +1069,7 @@ export class RunOnceScheduler implements IDisposable {
|
|||
* Returns true if scheduled.
|
||||
*/
|
||||
isScheduled(): boolean {
|
||||
return this.timeoutToken !== -1;
|
||||
return this.timeoutToken !== undefined;
|
||||
}
|
||||
|
||||
flush(): void {
|
||||
|
@ -1080,7 +1080,7 @@ export class RunOnceScheduler implements IDisposable {
|
|||
}
|
||||
|
||||
private onTimeout() {
|
||||
this.timeoutToken = -1;
|
||||
this.timeoutToken = undefined;
|
||||
if (this.runner) {
|
||||
this.doRun();
|
||||
}
|
||||
|
@ -1105,7 +1105,7 @@ export class ProcessTimeRunOnceScheduler {
|
|||
private timeout: number;
|
||||
|
||||
private counter: number;
|
||||
private intervalToken: any;
|
||||
private intervalToken: Timeout | undefined;
|
||||
private intervalHandler: () => void;
|
||||
|
||||
constructor(runner: () => void, delay: number) {
|
||||
|
@ -1115,7 +1115,7 @@ export class ProcessTimeRunOnceScheduler {
|
|||
this.runner = runner;
|
||||
this.timeout = delay;
|
||||
this.counter = 0;
|
||||
this.intervalToken = -1;
|
||||
this.intervalToken = undefined;
|
||||
this.intervalHandler = this.onInterval.bind(this);
|
||||
}
|
||||
|
||||
|
@ -1127,7 +1127,7 @@ export class ProcessTimeRunOnceScheduler {
|
|||
cancel(): void {
|
||||
if (this.isScheduled()) {
|
||||
clearInterval(this.intervalToken);
|
||||
this.intervalToken = -1;
|
||||
this.intervalToken = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1147,7 +1147,7 @@ export class ProcessTimeRunOnceScheduler {
|
|||
* Returns true if scheduled.
|
||||
*/
|
||||
isScheduled(): boolean {
|
||||
return this.intervalToken !== -1;
|
||||
return this.intervalToken !== undefined;
|
||||
}
|
||||
|
||||
private onInterval() {
|
||||
|
@ -1159,7 +1159,7 @@ export class ProcessTimeRunOnceScheduler {
|
|||
|
||||
// time elapsed
|
||||
clearInterval(this.intervalToken);
|
||||
this.intervalToken = -1;
|
||||
this.intervalToken = undefined;
|
||||
this.runner?.();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ export namespace Event {
|
|||
export function debounce<I, O>(event: Event<I>, merge: (last: O | undefined, event: I) => O, delay: number | typeof MicrotaskDelay = 100, leading = false, flushOnListenerRemove = false, leakWarningThreshold?: number, disposable?: DisposableStore): Event<O> {
|
||||
let subscription: IDisposable;
|
||||
let output: O | undefined = undefined;
|
||||
let handle: any = undefined;
|
||||
let handle: Timeout | undefined | null = undefined;
|
||||
let numDebouncedCalls = 0;
|
||||
let doFire: (() => void) | undefined;
|
||||
|
||||
|
@ -283,11 +283,13 @@ export namespace Event {
|
|||
};
|
||||
|
||||
if (typeof delay === 'number') {
|
||||
clearTimeout(handle);
|
||||
if (handle) {
|
||||
clearTimeout(handle);
|
||||
}
|
||||
handle = setTimeout(doFire, delay);
|
||||
} else {
|
||||
if (handle === undefined) {
|
||||
handle = 0;
|
||||
handle = null;
|
||||
queueMicrotask(doFire);
|
||||
}
|
||||
}
|
||||
|
@ -1412,7 +1414,7 @@ export class PauseableEmitter<T> extends Emitter<T> {
|
|||
export class DebounceEmitter<T> extends PauseableEmitter<T> {
|
||||
|
||||
private readonly _delay: number;
|
||||
private _handle: any | undefined;
|
||||
private _handle: Timeout | undefined;
|
||||
|
||||
constructor(options: EmitterOptions & { merge: (input: T[]) => T; delay?: number }) {
|
||||
super(options);
|
||||
|
|
|
@ -56,7 +56,7 @@ function parseLine(stackLine: string): ILocation | undefined {
|
|||
}
|
||||
|
||||
export class Debouncer implements IDisposable {
|
||||
private _timeout: any | undefined = undefined;
|
||||
private _timeout: Timeout | undefined = undefined;
|
||||
|
||||
public debounce(fn: () => void, timeoutMs: number): void {
|
||||
if (this._timeout !== undefined) {
|
||||
|
@ -76,7 +76,7 @@ export class Debouncer implements IDisposable {
|
|||
}
|
||||
|
||||
export class Throttler implements IDisposable {
|
||||
private _timeout: any | undefined = undefined;
|
||||
private _timeout: Timeout | undefined = undefined;
|
||||
|
||||
public throttle(fn: () => void, timeoutMs: number): void {
|
||||
if (this._timeout === undefined) {
|
||||
|
|
|
@ -326,7 +326,7 @@ export function signalFromObservable<T>(owner: DebugOwner | undefined, observabl
|
|||
export function debouncedObservableDeprecated<T>(observable: IObservable<T>, debounceMs: number, disposableStore: DisposableStore): IObservable<T | undefined> {
|
||||
const debouncedObservable = observableValue<T | undefined>('debounced', undefined);
|
||||
|
||||
let timeout: any = undefined;
|
||||
let timeout: Timeout | undefined = undefined;
|
||||
|
||||
disposableStore.add(autorun(reader => {
|
||||
/** @description debounce */
|
||||
|
@ -353,7 +353,7 @@ export function debouncedObservable<T>(observable: IObservable<T>, debounceMs: n
|
|||
let hasValue = false;
|
||||
let lastValue: T | undefined;
|
||||
|
||||
let timeout: any = undefined;
|
||||
let timeout: Timeout | undefined = undefined;
|
||||
|
||||
return observableFromEvent<T, void>(cb => {
|
||||
const d = autorun(reader => {
|
||||
|
@ -391,7 +391,7 @@ export function debouncedObservable<T>(observable: IObservable<T>, debounceMs: n
|
|||
export function wasEventTriggeredRecently(event: Event<any>, timeoutMs: number, disposableStore: DisposableStore): IObservable<boolean> {
|
||||
const observable = observableValue('triggeredRecently', false);
|
||||
|
||||
let timeout: any = undefined;
|
||||
let timeout: Timeout | undefined = undefined;
|
||||
|
||||
disposableStore.add(event(() => {
|
||||
observable.set(true, undefined);
|
||||
|
|
|
@ -156,7 +156,7 @@ export function isPortFree(port: number, timeout: number): Promise<boolean> {
|
|||
*/
|
||||
export function findFreePortFaster(startPort: number, giveUpAfter: number, timeout: number, hostname: string = '127.0.0.1'): Promise<number> {
|
||||
let resolved: boolean = false;
|
||||
let timeoutHandle: NodeJS.Timeout | undefined = undefined;
|
||||
let timeoutHandle: Timeout | undefined = undefined;
|
||||
let countTried: number = 1;
|
||||
const server = net.createServer({ pauseOnConnect: true });
|
||||
function doResolve(port: number, resolve: (port: number) => void) {
|
||||
|
|
|
@ -497,7 +497,7 @@ class ProtocolWriter {
|
|||
}
|
||||
}
|
||||
|
||||
private _writeNowTimeout: any = null;
|
||||
private _writeNowTimeout: Timeout | null = null;
|
||||
private _scheduleWriting(): void {
|
||||
if (this._writeNowTimeout) {
|
||||
return;
|
||||
|
@ -815,14 +815,14 @@ export class PersistentProtocol implements IMessagePassingProtocol {
|
|||
private _outgoingUnackMsg: Queue<ProtocolMessage>;
|
||||
private _outgoingMsgId: number;
|
||||
private _outgoingAckId: number;
|
||||
private _outgoingAckTimeout: any | null;
|
||||
private _outgoingAckTimeout: Timeout | null;
|
||||
|
||||
private _incomingMsgId: number;
|
||||
private _incomingAckId: number;
|
||||
private _incomingMsgLastTime: number;
|
||||
private _incomingAckTimeout: any | null;
|
||||
private _incomingAckTimeout: Timeout | null;
|
||||
|
||||
private _keepAliveInterval: any | null;
|
||||
private _keepAliveInterval: Timeout | null;
|
||||
|
||||
private _lastReplayRequestTime: number;
|
||||
private _lastSocketTimeoutTime: number;
|
||||
|
|
|
@ -324,7 +324,7 @@ export function deserialize(reader: IReader): any {
|
|||
|
||||
interface PendingRequest {
|
||||
request: IRawPromiseRequest | IRawEventListenRequest;
|
||||
timeoutTimer: any;
|
||||
timeoutTimer: Timeout;
|
||||
}
|
||||
|
||||
export class ChannelServer<TContext = string> implements IChannelServer<TContext>, IDisposable {
|
||||
|
|
|
@ -60,7 +60,7 @@ export class NodeSocket implements ISocket {
|
|||
};
|
||||
this.socket.on('error', this._errorListener);
|
||||
|
||||
let endTimeoutHandle: NodeJS.Timeout | undefined;
|
||||
let endTimeoutHandle: Timeout | undefined;
|
||||
this._closeListener = (hadError: boolean) => {
|
||||
this.traceSocketEvent(SocketDiagnosticsEventType.Close, { hadError });
|
||||
this._canWrite = false;
|
||||
|
|
|
@ -302,7 +302,7 @@ class LocalStorageURLCallbackProvider extends Disposable implements IURLCallback
|
|||
|
||||
private pendingCallbacks = new Set<number>();
|
||||
private lastTimeChecked = Date.now();
|
||||
private checkCallbacksTimeout: unknown | undefined = undefined;
|
||||
private checkCallbacksTimeout: Timeout | undefined = undefined;
|
||||
private onDidChangeLocalStorageDisposable: IDisposable | undefined;
|
||||
|
||||
constructor(private readonly _callbackRoute: string) {
|
||||
|
|
|
@ -446,7 +446,7 @@ export class CodeApplication extends Disposable {
|
|||
//#endregion
|
||||
|
||||
let macOpenFileURIs: IWindowOpenable[] = [];
|
||||
let runningTimeout: NodeJS.Timeout | undefined = undefined;
|
||||
let runningTimeout: Timeout | undefined = undefined;
|
||||
app.on('open-file', (event, path) => {
|
||||
path = normalizeNFC(path); // macOS only: normalize paths to NFC form
|
||||
|
||||
|
|
|
@ -357,7 +357,7 @@ class CodeMain {
|
|||
// Show a warning dialog after some timeout if it takes long to talk to the other instance
|
||||
// Skip this if we are running with --wait where it is expected that we wait for a while.
|
||||
// Also skip when gathering diagnostics (--status) which can take a longer time.
|
||||
let startupWarningDialogHandle: NodeJS.Timeout | undefined = undefined;
|
||||
let startupWarningDialogHandle: Timeout | undefined = undefined;
|
||||
if (!environmentMainService.args.wait && !environmentMainService.args.status) {
|
||||
startupWarningDialogHandle = setTimeout(() => {
|
||||
this.showStartupWarningDialog(
|
||||
|
|
|
@ -28,7 +28,7 @@ export class ObjectStream<T extends object> extends ObservableDisposable impleme
|
|||
* Interval reference that is used to periodically send
|
||||
* objects to the stream in the background.
|
||||
*/
|
||||
private timeoutHandle: ReturnType<typeof setTimeout> | undefined;
|
||||
private timeoutHandle: Timeout | undefined;
|
||||
|
||||
constructor(
|
||||
private readonly data: Generator<T, undefined>,
|
||||
|
@ -94,7 +94,7 @@ export class ObjectStream<T extends object> extends ObservableDisposable impleme
|
|||
}
|
||||
|
||||
clearTimeout(this.timeoutHandle);
|
||||
delete this.timeoutHandle;
|
||||
this.timeoutHandle = undefined;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -481,7 +481,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
|
|||
this._toggleReplaceBtn.setEnabled(this._isVisible && canReplace);
|
||||
}
|
||||
|
||||
private _revealTimeouts: any[] = [];
|
||||
private _revealTimeouts: Timeout[] = [];
|
||||
|
||||
private _reveal(): void {
|
||||
this._revealTimeouts.forEach(e => {
|
||||
|
|
|
@ -225,7 +225,7 @@ class WordHighlighter {
|
|||
private workerRequestValue: ResourceMap<DocumentHighlight[]> = new ResourceMap();
|
||||
|
||||
private lastCursorPositionChangeTime: number = 0;
|
||||
private renderDecorationsTimer: any = -1;
|
||||
private renderDecorationsTimer: Timeout | undefined = undefined;
|
||||
|
||||
private readonly _hasWordHighlights: IContextKey<boolean>;
|
||||
private _ignorePositionChangeEvent: boolean;
|
||||
|
@ -346,7 +346,7 @@ class WordHighlighter {
|
|||
this.workerRequestCompleted = false;
|
||||
|
||||
this.lastCursorPositionChangeTime = 0;
|
||||
this.renderDecorationsTimer = -1;
|
||||
this.renderDecorationsTimer = undefined;
|
||||
|
||||
// if there is a query already, highlight off that query
|
||||
if (WordHighlighter.query) {
|
||||
|
@ -495,9 +495,9 @@ class WordHighlighter {
|
|||
}
|
||||
|
||||
// Cancel any renderDecorationsTimer
|
||||
if (this.renderDecorationsTimer !== -1) {
|
||||
if (this.renderDecorationsTimer !== undefined) {
|
||||
clearTimeout(this.renderDecorationsTimer);
|
||||
this.renderDecorationsTimer = -1;
|
||||
this.renderDecorationsTimer = undefined;
|
||||
}
|
||||
|
||||
// Cancel any worker request
|
||||
|
@ -520,9 +520,9 @@ class WordHighlighter {
|
|||
this._removeAllDecorations(preservedModel);
|
||||
|
||||
// Cancel any renderDecorationsTimer
|
||||
if (this.renderDecorationsTimer !== -1) {
|
||||
if (this.renderDecorationsTimer !== undefined) {
|
||||
clearTimeout(this.renderDecorationsTimer);
|
||||
this.renderDecorationsTimer = -1;
|
||||
this.renderDecorationsTimer = undefined;
|
||||
}
|
||||
|
||||
// Cancel any worker request
|
||||
|
@ -761,7 +761,7 @@ class WordHighlighter {
|
|||
|
||||
if (currentTime >= minimumRenderTime) {
|
||||
// Synchronous
|
||||
this.renderDecorationsTimer = -1;
|
||||
this.renderDecorationsTimer = undefined;
|
||||
this.renderDecorations();
|
||||
} else {
|
||||
// Asynchronous
|
||||
|
@ -772,7 +772,7 @@ class WordHighlighter {
|
|||
}
|
||||
|
||||
private renderDecorations(): void {
|
||||
this.renderDecorationsTimer = -1;
|
||||
this.renderDecorationsTimer = undefined;
|
||||
// create new loop, iterate over current editors using this.codeEditorService.listCodeEditors(),
|
||||
// if the URI of that codeEditor is in the map, then add the decorations to the decorations array
|
||||
// then set the decorations for the editor
|
||||
|
|
|
@ -65,7 +65,7 @@ export class ExtensionsLifecycle extends Disposable {
|
|||
return new Promise<void>((c, e) => {
|
||||
|
||||
const extensionLifecycleProcess = this.start(lifecycleHook, lifecycleType, args, extension);
|
||||
let timeoutHandler: any;
|
||||
let timeoutHandler: Timeout | null;
|
||||
|
||||
const onexit = (error?: string) => {
|
||||
if (timeoutHandler) {
|
||||
|
|
|
@ -279,7 +279,7 @@ export class InMemoryFileSystemProvider extends Disposable implements
|
|||
readonly onDidChangeFile: Event<readonly IFileChange[]> = this._onDidChangeFile.event;
|
||||
|
||||
private _bufferedChanges: IFileChange[] = [];
|
||||
private _fireSoonHandle?: any;
|
||||
private _fireSoonHandle?: Timeout;
|
||||
|
||||
watch(resource: URI, opts: IWatchOptions): IDisposable {
|
||||
// ignore, fires for all changes...
|
||||
|
|
|
@ -228,7 +228,7 @@ export class LongRunningOperation extends Disposable {
|
|||
private currentOperationId = 0;
|
||||
private readonly currentOperationDisposables = this._register(new DisposableStore());
|
||||
private currentProgressRunner: IProgressRunner | undefined;
|
||||
private currentProgressTimeout: any;
|
||||
private currentProgressTimeout: Timeout | undefined = undefined;
|
||||
|
||||
constructor(
|
||||
private progressIndicator: IProgressIndicator
|
||||
|
|
|
@ -50,7 +50,7 @@ export default abstract class BaseErrorTelemetry {
|
|||
|
||||
private _telemetryService: ITelemetryService;
|
||||
private _flushDelay: number;
|
||||
private _flushHandle: any = -1;
|
||||
private _flushHandle: Timeout | undefined = undefined;
|
||||
private _buffer: ErrorEvent[] = [];
|
||||
protected readonly _disposables = new DisposableStore();
|
||||
|
||||
|
@ -118,10 +118,10 @@ export default abstract class BaseErrorTelemetry {
|
|||
this._buffer[idx].count! += 1;
|
||||
}
|
||||
|
||||
if (this._flushHandle === -1) {
|
||||
if (this._flushHandle === undefined) {
|
||||
this._flushHandle = setTimeout(() => {
|
||||
this._flushBuffer();
|
||||
this._flushHandle = -1;
|
||||
this._flushHandle = undefined;
|
||||
}, this._flushDelay);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import { IProcessDataEvent } from './terminal.js';
|
|||
|
||||
interface TerminalDataBuffer extends IDisposable {
|
||||
data: string[];
|
||||
timeoutId: any;
|
||||
timeoutId: Timeout;
|
||||
}
|
||||
|
||||
export class TerminalDataBufferer implements IDisposable {
|
||||
|
@ -37,7 +37,7 @@ export class TerminalDataBufferer implements IDisposable {
|
|||
const timeoutId = setTimeout(() => this.flushBuffer(id), throttleBy);
|
||||
buffer = {
|
||||
data: [data],
|
||||
timeoutId: timeoutId,
|
||||
timeoutId,
|
||||
dispose: () => {
|
||||
clearTimeout(timeoutId);
|
||||
this.flushBuffer(id);
|
||||
|
|
|
@ -325,7 +325,7 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
|
|||
private _terminal?: Terminal;
|
||||
readonly capabilities = this._register(new TerminalCapabilityStore());
|
||||
private _hasUpdatedTelemetry: boolean = false;
|
||||
private _activationTimeout: any;
|
||||
private _activationTimeout: Timeout | undefined;
|
||||
private _commonProtocolDisposables: IDisposable[] = [];
|
||||
|
||||
private _seenSequences: Set<string> = new Set();
|
||||
|
|
|
@ -63,8 +63,8 @@ export class PtyHostService extends Disposable implements IPtyHostService {
|
|||
private _wasQuitRequested = false;
|
||||
private _restartCount = 0;
|
||||
private _isResponsive = true;
|
||||
private _heartbeatFirstTimeout?: NodeJS.Timeout;
|
||||
private _heartbeatSecondTimeout?: NodeJS.Timeout;
|
||||
private _heartbeatFirstTimeout?: Timeout;
|
||||
private _heartbeatSecondTimeout?: Timeout;
|
||||
|
||||
private readonly _onPtyHostExit = this._register(new Emitter<number>());
|
||||
readonly onPtyHostExit = this._onPtyHostExit.event;
|
||||
|
|
|
@ -105,15 +105,15 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
|
|||
private static _lastKillOrStart = 0;
|
||||
private _exitCode: number | undefined;
|
||||
private _exitMessage: string | undefined;
|
||||
private _closeTimeout: any;
|
||||
private _closeTimeout: Timeout | undefined;
|
||||
private _ptyProcess: IPty | undefined;
|
||||
private _currentTitle: string = '';
|
||||
private _processStartupComplete: Promise<void> | undefined;
|
||||
private _windowsShellHelper: WindowsShellHelper | undefined;
|
||||
private _childProcessMonitor: ChildProcessMonitor | undefined;
|
||||
private _titleInterval: NodeJS.Timeout | null = null;
|
||||
private _titleInterval: Timeout | undefined;
|
||||
private _writeQueue: IWriteObject[] = [];
|
||||
private _writeTimeout: NodeJS.Timeout | undefined;
|
||||
private _writeTimeout: Timeout | undefined;
|
||||
private _delayedResizer: DelayedResizer | undefined;
|
||||
private readonly _initialCwd: string;
|
||||
private readonly _ptyOptions: IPtyForkOptions | IWindowsPtyForkOptions;
|
||||
|
@ -197,7 +197,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
|
|||
this._register(toDisposable(() => {
|
||||
if (this._titleInterval) {
|
||||
clearInterval(this._titleInterval);
|
||||
this._titleInterval = null;
|
||||
this._titleInterval = undefined;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
@ -678,7 +678,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
|
|||
class DelayedResizer extends Disposable {
|
||||
rows: number | undefined;
|
||||
cols: number | undefined;
|
||||
private _timeout: NodeJS.Timeout;
|
||||
private _timeout: Timeout;
|
||||
|
||||
private readonly _onTrigger = this._register(new Emitter<{ rows?: number; cols?: number }>());
|
||||
get onTrigger(): Event<{ rows?: number; cols?: number }> { return this._onTrigger.event; }
|
||||
|
|
|
@ -69,7 +69,7 @@ class RemoteExtensionHostAgentServer extends Disposable implements IServerAPI {
|
|||
private readonly _serverBasePath: string | undefined;
|
||||
private readonly _serverProductPath: string;
|
||||
|
||||
private shutdownTimer: NodeJS.Timeout | undefined;
|
||||
private shutdownTimer: Timeout | undefined;
|
||||
|
||||
constructor(
|
||||
private readonly _socketServer: SocketServer<RemoteAgentConnectionContext>,
|
||||
|
|
|
@ -19,7 +19,7 @@ class DecorationRequestsQueue {
|
|||
private _requests = new Map<number, DecorationRequest>();
|
||||
private _resolver = new Map<number, DeferredPromise<DecorationData>>();
|
||||
|
||||
private _timer: any;
|
||||
private _timer: Timeout | undefined;
|
||||
|
||||
constructor(
|
||||
private readonly _proxy: ExtHostDecorationsShape,
|
||||
|
@ -45,7 +45,7 @@ class DecorationRequestsQueue {
|
|||
}
|
||||
|
||||
private _processQueue(): void {
|
||||
if (typeof this._timer === 'number') {
|
||||
if (this._timer !== undefined) {
|
||||
// already queued
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class ExtHostNotebookDocumentSaveParticipant implements IStoredFileWorkingCopySa
|
|||
return undefined;
|
||||
}
|
||||
|
||||
let _warningTimeout: any;
|
||||
let _warningTimeout: Timeout;
|
||||
|
||||
const p = new Promise<any>((resolve, reject) => {
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
|
|||
private readonly _onDidChangeValueEmitter = new Emitter<string>();
|
||||
private readonly _onDidTriggerButtonEmitter = new Emitter<QuickInputButton>();
|
||||
private readonly _onDidHideEmitter = new Emitter<void>();
|
||||
private _updateTimeout: any;
|
||||
private _updateTimeout: Timeout | undefined;
|
||||
private _pendingUpdate: TransferQuickInput = { id: this._id };
|
||||
|
||||
private _disposed = false;
|
||||
|
|
|
@ -57,7 +57,7 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
|
|||
readonly internal: ICommandDto;
|
||||
};
|
||||
|
||||
private _timeoutHandle: any;
|
||||
private _timeoutHandle: Timeout | undefined;
|
||||
private _accessibilityInformation?: vscode.AccessibilityInformation;
|
||||
|
||||
constructor(proxy: MainThreadStatusBarShape, commands: CommandsConverter, staticItems: ReadonlyMap<string, StatusBarItemDto>, extension: IExtensionDescription, id?: string, alignment?: ExtHostStatusBarAlignment, priority?: number, _onDispose?: () => void);
|
||||
|
@ -389,7 +389,7 @@ export class ExtHostStatusBar implements ExtHostStatusBarShape {
|
|||
|
||||
setStatusBarMessage(text: string, timeoutOrThenable?: number | Thenable<any>): Disposable {
|
||||
const d = this._statusMessage.setMessage(text);
|
||||
let handle: any;
|
||||
let handle: Timeout | undefined;
|
||||
|
||||
if (typeof timeoutOrThenable === 'number') {
|
||||
handle = setTimeout(() => d.dispose(), timeoutOrThenable);
|
||||
|
|
|
@ -222,7 +222,7 @@ const fetchFeatureUse: FetchFeatureUseEvent = {
|
|||
manualRedirect: 0,
|
||||
};
|
||||
|
||||
let timer: NodeJS.Timeout | undefined;
|
||||
let timer: Timeout | undefined;
|
||||
const enableFeatureUseTelemetry = false;
|
||||
function recordFetchFeatureUse(mainThreadTelemetry: MainThreadTelemetryShape, feature: keyof typeof fetchFeatureUse) {
|
||||
if (enableFeatureUseTelemetry && !fetchFeatureUse[feature]++) {
|
||||
|
@ -232,7 +232,7 @@ function recordFetchFeatureUse(mainThreadTelemetry: MainThreadTelemetryShape, fe
|
|||
timer = setTimeout(() => {
|
||||
mainThreadTelemetry.$publicLog2<FetchFeatureUseEvent, FetchFeatureUseClassification>('fetchFeatureUse', fetchFeatureUse);
|
||||
}, 10000); // collect additional features for 10 seconds
|
||||
timer.unref();
|
||||
(timer as unknown as NodeJS.Timeout).unref?.();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ export class CompositeBarActionViewItem extends BaseActionViewItem {
|
|||
|
||||
private badgeContent: HTMLElement | undefined;
|
||||
private readonly badgeDisposable = this._register(new MutableDisposable<DisposableStore>());
|
||||
private mouseUpTimeout: any;
|
||||
private mouseUpTimeout: Timeout | undefined;
|
||||
private keybindingLabel: string | undefined | null;
|
||||
|
||||
constructor(
|
||||
|
|
|
@ -1077,8 +1077,8 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupsView {
|
|||
onDragEnd: e => overlay.classList.remove('visible')
|
||||
}));
|
||||
|
||||
let horizontalOpenerTimeout: any;
|
||||
let verticalOpenerTimeout: any;
|
||||
let horizontalOpenerTimeout: Timeout | undefined;
|
||||
let verticalOpenerTimeout: Timeout | undefined;
|
||||
let lastOpenHorizontalPosition: Position | undefined;
|
||||
let lastOpenVerticalPosition: Position | undefined;
|
||||
const openPartAtPosition = (position: Position) => {
|
||||
|
|
|
@ -191,7 +191,7 @@ export class NotificationsStatus extends Disposable {
|
|||
|
||||
// Create new
|
||||
let statusMessageEntry: IStatusbarEntryAccessor;
|
||||
let showHandle: any = setTimeout(() => {
|
||||
let showHandle: Timeout | undefined = setTimeout(() => {
|
||||
statusMessageEntry = this.statusbarService.addEntry(
|
||||
{
|
||||
name: localize('status.message', "Status Message"),
|
||||
|
@ -202,11 +202,11 @@ export class NotificationsStatus extends Disposable {
|
|||
StatusbarAlignment.LEFT,
|
||||
Number.NEGATIVE_INFINITY /* last entry */
|
||||
);
|
||||
showHandle = null;
|
||||
showHandle = undefined;
|
||||
}, showAfter);
|
||||
|
||||
// Dispose function takes care of timeouts and actual entry
|
||||
let hideHandle: any;
|
||||
let hideHandle: Timeout | undefined;
|
||||
const statusMessageDispose = {
|
||||
dispose: () => {
|
||||
if (showHandle) {
|
||||
|
|
|
@ -289,7 +289,7 @@ export class NotificationsToasts extends Themable implements INotificationsToast
|
|||
disposables.add(addDisposableListener(notificationToastContainer, EventType.MOUSE_OUT, () => isMouseOverToast = false));
|
||||
|
||||
// Install Timers to Purge Notification
|
||||
let purgeTimeoutHandle: any;
|
||||
let purgeTimeoutHandle: Timeout;
|
||||
let listener: IDisposable;
|
||||
|
||||
const hideAfterTimeout = () => {
|
||||
|
|
|
@ -19,7 +19,7 @@ import { ICellDiffInfo } from './notebookCellChanges.js';
|
|||
|
||||
export class OverlayToolbarDecorator extends Disposable {
|
||||
|
||||
private _timeout: any | undefined = undefined;
|
||||
private _timeout: Timeout | undefined = undefined;
|
||||
private readonly overlayDisposables = this._register(new DisposableStore());
|
||||
|
||||
constructor(
|
||||
|
|
|
@ -46,7 +46,7 @@ class SimpleBrowserOverlayWidget {
|
|||
|
||||
private readonly _showStore = new DisposableStore();
|
||||
|
||||
private _timeout: any | undefined = undefined;
|
||||
private _timeout: Timeout | undefined = undefined;
|
||||
|
||||
private _activeBrowserType: BrowserType | undefined = undefined;
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ export class CommentNode<T extends IRange | ICellRange> extends Disposable {
|
|||
private _avatar: HTMLElement;
|
||||
private readonly _md: MutableDisposable<IMarkdownRenderResult> = this._register(new MutableDisposable());
|
||||
private _plainText: HTMLElement | undefined;
|
||||
private _clearTimeout: any;
|
||||
private _clearTimeout: Timeout | null;
|
||||
|
||||
private _editAction: Action | null = null;
|
||||
private _commentEditContainer: HTMLElement | null = null;
|
||||
|
|
|
@ -22,7 +22,7 @@ export class LogsDataCleaner extends Disposable {
|
|||
}
|
||||
|
||||
private cleanUpOldLogsSoon(): void {
|
||||
let handle: any = setTimeout(async () => {
|
||||
let handle: Timeout | undefined = setTimeout(async () => {
|
||||
handle = undefined;
|
||||
const stat = await this.fileService.resolve(dirname(this.environmentService.logsHome));
|
||||
if (stat.children) {
|
||||
|
|
|
@ -67,7 +67,7 @@ class NotebookKernelDetection extends Disposable implements IWorkbenchContributi
|
|||
}
|
||||
}));
|
||||
|
||||
let timer: any = null;
|
||||
let timer: Timeout | null = null;
|
||||
|
||||
this._localDisposableStore.add(this._extensionService.onDidChangeExtensionsStatus(() => {
|
||||
if (timer) {
|
||||
|
|
|
@ -440,7 +440,7 @@ class CellOutputElement extends Disposable {
|
|||
return nls.localize('unavailableRenderInfo', "renderer not available");
|
||||
}
|
||||
|
||||
private _outputHeightTimer: any = null;
|
||||
private _outputHeightTimer: Timeout | null = null;
|
||||
|
||||
private _validateFinalOutputHeight(synchronous: boolean) {
|
||||
if (this._outputHeightTimer !== null) {
|
||||
|
@ -621,7 +621,7 @@ export class CellOutputContainer extends CellContentPart {
|
|||
}
|
||||
}
|
||||
|
||||
private _outputHeightTimer: any = null;
|
||||
private _outputHeightTimer: Timeout | null = null;
|
||||
|
||||
private _validateFinalOutputHeight(synchronous: boolean) {
|
||||
if (this._outputHeightTimer !== null) {
|
||||
|
|
|
@ -500,7 +500,7 @@ async function webviewPreloads(ctx: PreloadContext) {
|
|||
private readonly _observer: ResizeObserver;
|
||||
|
||||
private readonly _observedElements = new WeakMap<Element, IObservedElement>();
|
||||
private _outputResizeTimer: any;
|
||||
private _outputResizeTimer: Timeout | undefined;
|
||||
|
||||
constructor() {
|
||||
this._observer = new ResizeObserver(entries => {
|
||||
|
@ -584,7 +584,7 @@ async function webviewPreloads(ctx: PreloadContext) {
|
|||
};
|
||||
|
||||
let previousDelta: number | undefined;
|
||||
let scrollTimeout: any /* NodeJS.Timeout */ | undefined;
|
||||
let scrollTimeout: Timeout | undefined;
|
||||
let scrolledElement: Element | undefined;
|
||||
let lastTimeScrolled: number | undefined;
|
||||
function flagRecentlyScrolled(node: Element, deltaY?: number) {
|
||||
|
|
|
@ -1660,7 +1660,7 @@ class SCMInputWidget {
|
|||
private validation: IInputValidation | undefined;
|
||||
private validationContextView: IOpenContextView | undefined;
|
||||
private validationHasFocus: boolean = false;
|
||||
private _validationTimer: any;
|
||||
private _validationTimer: Timeout | undefined;
|
||||
|
||||
// This is due to "Setup height change listener on next tick" above
|
||||
// https://github.com/microsoft/vscode/issues/108067
|
||||
|
@ -1830,7 +1830,7 @@ class SCMInputWidget {
|
|||
private setValidation(validation: IInputValidation | undefined, options?: { focus?: boolean; timeout?: boolean }) {
|
||||
if (this._validationTimer) {
|
||||
clearTimeout(this._validationTimer);
|
||||
this._validationTimer = 0;
|
||||
this._validationTimer = undefined;
|
||||
}
|
||||
|
||||
this.validation = validation;
|
||||
|
|
|
@ -1346,7 +1346,7 @@ export class TypeAheadAddon extends Disposable implements ITerminalAddon {
|
|||
}));
|
||||
this._register(this._processManager.onBeforeProcessData(e => this._onBeforeProcessData(e)));
|
||||
|
||||
let nextStatsSend: any;
|
||||
let nextStatsSend: Timeout | undefined;
|
||||
this._register(stats.onChange(() => {
|
||||
if (!nextStatsSend) {
|
||||
nextStatsSend = setTimeout(() => {
|
||||
|
|
|
@ -63,7 +63,7 @@ export class WebviewViewPane extends ViewPane {
|
|||
private readonly viewState: MementoObject;
|
||||
private readonly extensionId?: ExtensionIdentifier;
|
||||
|
||||
private _repositionTimeout?: any;
|
||||
private _repositionTimeout?: Timeout;
|
||||
|
||||
constructor(
|
||||
options: IViewletViewOptions,
|
||||
|
|
|
@ -146,7 +146,7 @@ export class WebWorkerExtensionHost extends Disposable implements IExtensionHost
|
|||
let port!: MessagePort;
|
||||
let barrierError: Error | null = null;
|
||||
let barrierHasError = false;
|
||||
let startTimeout: any = null;
|
||||
let startTimeout: Timeout | undefined = undefined;
|
||||
|
||||
const rejectBarrier = (exitCode: number, error: Error) => {
|
||||
barrierError = error;
|
||||
|
|
|
@ -293,7 +293,7 @@ export class NativeLocalProcessExtensionHost implements IExtensionHost {
|
|||
}
|
||||
|
||||
// Help in case we fail to start it
|
||||
let startupTimeoutHandle: any;
|
||||
let startupTimeoutHandle: Timeout | undefined;
|
||||
if (!this._environmentService.isBuilt && !this._environmentService.remoteAuthority || this._isExtensionDevHost) {
|
||||
startupTimeoutHandle = setTimeout(() => {
|
||||
this._logService.error(`[LocalProcessExtensionHost]: Extension host did not start in 10 seconds (debugBrk: ${this._isExtensionDevDebugBrk})`);
|
||||
|
@ -409,7 +409,7 @@ export class NativeLocalProcessExtensionHost implements IExtensionHost {
|
|||
// 2) wait for the incoming `initialized` event.
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
|
||||
let timeoutHandle: any;
|
||||
let timeoutHandle: Timeout;
|
||||
const installTimeoutCheck = () => {
|
||||
timeoutHandle = setTimeout(() => {
|
||||
reject('The local extension host took longer than 60s to send its ready message.');
|
||||
|
|
|
@ -120,7 +120,7 @@ export class ProgressService extends Disposable implements IProgressService {
|
|||
|
||||
const promise = callback(task[1]);
|
||||
|
||||
let delayHandle: any = setTimeout(() => {
|
||||
let delayHandle: Timeout | undefined = setTimeout(() => {
|
||||
delayHandle = undefined;
|
||||
this.windowProgressStack.unshift(task);
|
||||
this.updateWindowProgress();
|
||||
|
@ -370,7 +370,7 @@ export class ProgressService extends Disposable implements IProgressService {
|
|||
};
|
||||
|
||||
let notificationHandle: INotificationHandle | undefined;
|
||||
let notificationTimeout: any | undefined;
|
||||
let notificationTimeout: Timeout | undefined;
|
||||
let titleAndMessage: string | undefined; // hoisted to make sure a delayed notification shows the most recent message
|
||||
|
||||
const updateNotification = (step?: IProgressStep): void => {
|
||||
|
@ -386,7 +386,7 @@ export class ProgressService extends Disposable implements IProgressService {
|
|||
|
||||
// create notification now or after a delay
|
||||
if (typeof options.delay === 'number' && options.delay > 0) {
|
||||
if (typeof notificationTimeout !== 'number') {
|
||||
if (notificationTimeout !== undefined) {
|
||||
notificationTimeout = setTimeout(() => notificationHandle = createNotification(titleAndMessage!, options.priority, step?.increment), options.delay);
|
||||
}
|
||||
} else {
|
||||
|
@ -466,7 +466,7 @@ export class ProgressService extends Disposable implements IProgressService {
|
|||
|
||||
private showOnActivityBar<P extends Promise<R>, R = unknown>(viewletId: string, options: IProgressCompositeOptions, promise: P): void {
|
||||
let activityProgress: IDisposable;
|
||||
let delayHandle: any = setTimeout(() => {
|
||||
let delayHandle: Timeout | undefined = setTimeout(() => {
|
||||
delayHandle = undefined;
|
||||
const handle = this.activityService.showViewContainerActivity(viewletId, { badge: new ProgressBadge(() => '') });
|
||||
const startTimeVisible = Date.now();
|
||||
|
|
|
@ -329,7 +329,7 @@ export class BatchedCollector<T> {
|
|||
private totalNumberCompleted = 0;
|
||||
private batch: T[] = [];
|
||||
private batchSize = 0;
|
||||
private timeoutHandle: any;
|
||||
private timeoutHandle: Timeout | undefined;
|
||||
|
||||
constructor(private maxBatchSize: number, private cb: (items: T[]) => void) {
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ export class BatchedCollector<T> {
|
|||
|
||||
if (this.timeoutHandle) {
|
||||
clearTimeout(this.timeoutHandle);
|
||||
this.timeoutHandle = 0;
|
||||
this.timeoutHandle = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue