cleanup any-usages (#274732)

* cleanup any-usages

https://github.com/microsoft/vscode/issues/274723

* ignore location for now
This commit is contained in:
Johannes Rieken
2025-11-03 14:45:30 +01:00
committed by GitHub
parent 1b7044d9ef
commit 0ce8e5c6c7
21 changed files with 63 additions and 80 deletions

View File

@@ -671,27 +671,19 @@ export default tseslint.config(
'src/vs/editor/contrib/find/browser/findWidgetSearchHistory.ts', 'src/vs/editor/contrib/find/browser/findWidgetSearchHistory.ts',
'src/vs/editor/contrib/find/browser/replaceWidgetHistory.ts', 'src/vs/editor/contrib/find/browser/replaceWidgetHistory.ts',
'src/vs/editor/contrib/folding/browser/folding.ts', 'src/vs/editor/contrib/folding/browser/folding.ts',
'src/vs/editor/contrib/format/browser/format.ts',
'src/vs/editor/contrib/gotoSymbol/browser/goToCommands.ts', 'src/vs/editor/contrib/gotoSymbol/browser/goToCommands.ts',
'src/vs/editor/contrib/gotoSymbol/browser/symbolNavigation.ts', 'src/vs/editor/contrib/gotoSymbol/browser/symbolNavigation.ts',
'src/vs/editor/contrib/hover/browser/hoverActions.ts', 'src/vs/editor/contrib/hover/browser/hoverActions.ts',
'src/vs/editor/contrib/inlineCompletions/browser/structuredLogger.ts', 'src/vs/editor/contrib/inlineCompletions/browser/structuredLogger.ts',
'src/vs/editor/contrib/inlineCompletions/browser/utils.ts', 'src/vs/editor/contrib/inlineCompletions/browser/utils.ts',
'src/vs/editor/contrib/smartSelect/browser/smartSelect.ts', 'src/vs/editor/contrib/smartSelect/browser/smartSelect.ts',
'src/vs/editor/contrib/snippet/browser/snippetParser.ts',
'src/vs/editor/contrib/stickyScroll/browser/stickyScrollModelProvider.ts', 'src/vs/editor/contrib/stickyScroll/browser/stickyScrollModelProvider.ts',
'src/vs/editor/contrib/suggest/browser/suggest.ts',
'src/vs/editor/contrib/suggest/browser/suggestAlternatives.ts',
'src/vs/editor/contrib/suggest/browser/suggestCommitCharacters.ts',
'src/vs/editor/contrib/suggest/browser/suggestController.ts',
'src/vs/editor/contrib/unicodeHighlighter/browser/unicodeHighlighter.ts', 'src/vs/editor/contrib/unicodeHighlighter/browser/unicodeHighlighter.ts',
'src/vs/editor/contrib/wordHighlighter/browser/wordHighlighter.ts', 'src/vs/editor/contrib/wordHighlighter/browser/wordHighlighter.ts',
'src/vs/editor/standalone/common/monarch/monarchCommon.ts', 'src/vs/editor/standalone/common/monarch/monarchCommon.ts',
'src/vs/editor/standalone/common/monarch/monarchCompile.ts', 'src/vs/editor/standalone/common/monarch/monarchCompile.ts',
'src/vs/editor/standalone/common/monarch/monarchLexer.ts', 'src/vs/editor/standalone/common/monarch/monarchLexer.ts',
'src/vs/editor/standalone/common/monarch/monarchTypes.ts', 'src/vs/editor/standalone/common/monarch/monarchTypes.ts',
'src/vs/editor/contrib/gotoSymbol/browser/peek/referencesController.ts',
'src/vs/editor/contrib/gotoSymbol/browser/peek/referencesWidget.ts',
'src/vs/editor/contrib/inlineCompletions/browser/controller/commands.ts', 'src/vs/editor/contrib/inlineCompletions/browser/controller/commands.ts',
'src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.ts', 'src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.ts',
'src/vs/editor/contrib/inlineCompletions/browser/model/typingSpeed.ts', 'src/vs/editor/contrib/inlineCompletions/browser/model/typingSpeed.ts',
@@ -741,19 +733,8 @@ export default tseslint.config(
'src/vs/workbench/api/common/extHostTreeViews.ts', 'src/vs/workbench/api/common/extHostTreeViews.ts',
'src/vs/workbench/api/common/extHostTypeConverters.ts', 'src/vs/workbench/api/common/extHostTypeConverters.ts',
'src/vs/workbench/api/common/extHostTypes.ts', 'src/vs/workbench/api/common/extHostTypes.ts',
'src/vs/workbench/api/common/extHostTypes/diagnostic.ts',
'src/vs/workbench/api/common/extHostTypes/es5ClassCompat.ts', 'src/vs/workbench/api/common/extHostTypes/es5ClassCompat.ts',
'src/vs/workbench/api/common/extHostTypes/location.ts', 'src/vs/workbench/api/common/extHostTypes/location.ts',
'src/vs/workbench/api/common/extHostTypes/markdownString.ts',
'src/vs/workbench/api/common/extHostTypes/notebooks.ts',
'src/vs/workbench/api/common/extHostTypes/position.ts',
'src/vs/workbench/api/common/extHostTypes/range.ts',
'src/vs/workbench/api/common/extHostTypes/selection.ts',
'src/vs/workbench/api/common/extHostTypes/snippetString.ts',
'src/vs/workbench/api/common/extHostTypes/snippetTextEdit.ts',
'src/vs/workbench/api/common/extHostTypes/symbolInformation.ts',
'src/vs/workbench/api/common/extHostTypes/textEdit.ts',
'src/vs/workbench/api/common/extHostTypes/workspaceEdit.ts',
'src/vs/workbench/api/common/extHostWebview.ts', 'src/vs/workbench/api/common/extHostWebview.ts',
'src/vs/workbench/api/common/extHostWebviewMessaging.ts', 'src/vs/workbench/api/common/extHostWebviewMessaging.ts',
'src/vs/workbench/api/common/extHostWebviewPanels.ts', 'src/vs/workbench/api/common/extHostWebviewPanels.ts',

View File

@@ -460,7 +460,7 @@ export function getOnTypeFormattingEdits(
}); });
} }
function isFormattingOptions(obj: any): obj is FormattingOptions { function isFormattingOptions(obj: unknown): obj is FormattingOptions {
const candidate = obj as FormattingOptions | undefined; const candidate = obj as FormattingOptions | undefined;
return !!candidate && typeof candidate === 'object' && typeof candidate.tabSize === 'number' && typeof candidate.insertSpaces === 'boolean'; return !!candidate && typeof candidate === 'object' && typeof candidate.tabSize === 'number' && typeof candidate.insertSpaces === 'boolean';

View File

@@ -245,7 +245,7 @@ export abstract class ReferencesController implements IEditorContribution {
this._requestIdPool += 1; // Cancel pending requests this._requestIdPool += 1; // Cancel pending requests
} }
private _gotoReference(ref: Location, pinned: boolean): Promise<any> { private _gotoReference(ref: Location, pinned: boolean): Promise<unknown> {
this._widget?.hide(); this._widget?.hide();
this._ignoreModelChangeEvent = true; this._ignoreModelChangeEvent = true;
@@ -397,9 +397,9 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
when: ContextKeyExpr.and(ctxReferenceSearchVisible, WorkbenchListFocusContextKey, WorkbenchTreeElementCanCollapse.negate(), WorkbenchTreeElementCanExpand.negate()), when: ContextKeyExpr.and(ctxReferenceSearchVisible, WorkbenchListFocusContextKey, WorkbenchTreeElementCanCollapse.negate(), WorkbenchTreeElementCanExpand.negate()),
handler(accessor: ServicesAccessor) { handler(accessor: ServicesAccessor) {
const listService = accessor.get(IListService); const listService = accessor.get(IListService);
const focus = <any[]>listService.lastFocusedList?.getFocus(); const focus = <unknown[]>listService.lastFocusedList?.getFocus();
if (Array.isArray(focus) && focus[0] instanceof OneReference) { if (Array.isArray(focus) && focus[0] instanceof OneReference) {
withController(accessor, controller => controller.revealReference(focus[0])); withController(accessor, controller => controller.revealReference(focus[0] as OneReference));
} }
} }
}); });
@@ -414,17 +414,17 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
when: ContextKeyExpr.and(ctxReferenceSearchVisible, WorkbenchListFocusContextKey, WorkbenchTreeElementCanCollapse.negate(), WorkbenchTreeElementCanExpand.negate()), when: ContextKeyExpr.and(ctxReferenceSearchVisible, WorkbenchListFocusContextKey, WorkbenchTreeElementCanCollapse.negate(), WorkbenchTreeElementCanExpand.negate()),
handler(accessor: ServicesAccessor) { handler(accessor: ServicesAccessor) {
const listService = accessor.get(IListService); const listService = accessor.get(IListService);
const focus = <any[]>listService.lastFocusedList?.getFocus(); const focus = <unknown[]>listService.lastFocusedList?.getFocus();
if (Array.isArray(focus) && focus[0] instanceof OneReference) { if (Array.isArray(focus) && focus[0] instanceof OneReference) {
withController(accessor, controller => controller.openReference(focus[0], true, true)); withController(accessor, controller => controller.openReference(focus[0] as OneReference, true, true));
} }
} }
}); });
CommandsRegistry.registerCommand('openReference', (accessor) => { CommandsRegistry.registerCommand('openReference', (accessor) => {
const listService = accessor.get(IListService); const listService = accessor.get(IListService);
const focus = <any[]>listService.lastFocusedList?.getFocus(); const focus = <unknown[]>listService.lastFocusedList?.getFocus();
if (Array.isArray(focus) && focus[0] instanceof OneReference) { if (Array.isArray(focus) && focus[0] instanceof OneReference) {
withController(accessor, controller => controller.openReference(focus[0], false, true)); withController(accessor, controller => controller.openReference(focus[0] as OneReference, false, true));
} }
}); });

View File

@@ -432,7 +432,7 @@ export class ReferenceWidget extends peekView.PeekViewWidget {
}, undefined)); }, undefined));
// listen on selection and focus // listen on selection and focus
const onEvent = (element: any, kind: 'show' | 'goto' | 'side') => { const onEvent = (element: TreeElement | undefined, kind: 'show' | 'goto' | 'side') => {
if (element instanceof OneReference) { if (element instanceof OneReference) {
if (kind === 'show') { if (kind === 'show') {
this._revealReference(element, false); this._revealReference(element, false);
@@ -467,7 +467,7 @@ export class ReferenceWidget extends peekView.PeekViewWidget {
this._splitView.resizeView(0, widthInPixel * this.layoutData.ratio); this._splitView.resizeView(0, widthInPixel * this.layoutData.ratio);
} }
setSelection(selection: OneReference): Promise<any> { setSelection(selection: OneReference): Promise<unknown> {
return this._revealReference(selection, true).then(() => { return this._revealReference(selection, true).then(() => {
if (!this._model) { if (!this._model) {
// disposed // disposed
@@ -479,7 +479,7 @@ export class ReferenceWidget extends peekView.PeekViewWidget {
}); });
} }
setModel(newModel: ReferencesModel | undefined): Promise<any> { setModel(newModel: ReferencesModel | undefined): Promise<unknown> {
// clean up // clean up
this._disposeOnNewModel.clear(); this._disposeOnNewModel.clear();
this._model = newModel; this._model = newModel;
@@ -489,7 +489,7 @@ export class ReferenceWidget extends peekView.PeekViewWidget {
return Promise.resolve(); return Promise.resolve();
} }
private _onNewModel(): Promise<any> { private _onNewModel(): Promise<unknown> {
if (!this._model) { if (!this._model) {
return Promise.resolve(undefined); return Promise.resolve(undefined);
} }

View File

@@ -129,7 +129,7 @@ export class Scanner {
export abstract class Marker { export abstract class Marker {
readonly _markerBrand: any; readonly _markerBrand: undefined;
public parent!: Marker; public parent!: Marker;
protected _children: Marker[] = []; protected _children: Marker[] = [];

View File

@@ -323,7 +323,7 @@ export async function provideSuggestionItems(
if (token.isCancellationRequested) { if (token.isCancellationRequested) {
disposables.dispose(); disposables.dispose();
return Promise.reject<any>(new CancellationError()); return Promise.reject(new CancellationError());
} }
return new CompletionItemModel( return new CompletionItemModel(
@@ -402,7 +402,7 @@ CommandsRegistry.registerCommand('_executeCompletionItemProvider', async (access
suggestions: [] suggestions: []
}; };
const resolving: Promise<any>[] = []; const resolving: Promise<unknown>[] = [];
const actualPosition = ref.object.textEditorModel.validatePosition(position); const actualPosition = ref.object.textEditorModel.validatePosition(position);
const completions = await provideSuggestionItems(completionProvider, ref.object.textEditorModel, actualPosition, undefined, { triggerCharacter: triggerCharacter ?? undefined, triggerKind: triggerCharacter ? languages.CompletionTriggerKind.TriggerCharacter : languages.CompletionTriggerKind.Invoke }); const completions = await provideSuggestionItems(completionProvider, ref.object.textEditorModel, actualPosition, undefined, { triggerCharacter: triggerCharacter ?? undefined, triggerKind: triggerCharacter ? languages.CompletionTriggerKind.TriggerCharacter : languages.CompletionTriggerKind.Invoke });
for (const item of completions.items) { for (const item of completions.items) {

View File

@@ -17,7 +17,7 @@ export class SuggestAlternatives {
private _index: number = 0; private _index: number = 0;
private _model: CompletionModel | undefined; private _model: CompletionModel | undefined;
private _acceptNext: ((selected: ISelectedSuggestion) => any) | undefined; private _acceptNext: ((selected: ISelectedSuggestion) => unknown) | undefined;
private _listener: IDisposable | undefined; private _listener: IDisposable | undefined;
private _ignore: boolean | undefined; private _ignore: boolean | undefined;
@@ -40,7 +40,7 @@ export class SuggestAlternatives {
this._ignore = false; this._ignore = false;
} }
set({ model, index }: ISelectedSuggestion, acceptNext: (selected: ISelectedSuggestion) => any): void { set({ model, index }: ISelectedSuggestion, acceptNext: (selected: ISelectedSuggestion) => unknown): void {
// no suggestions -> nothing to do // no suggestions -> nothing to do
if (model.items.length === 0) { if (model.items.length === 0) {

View File

@@ -20,7 +20,7 @@ export class CommitCharacterController {
readonly item: ISelectedSuggestion; readonly item: ISelectedSuggestion;
}; };
constructor(editor: ICodeEditor, widget: SuggestWidget, model: SuggestModel, accept: (selected: ISelectedSuggestion) => any) { constructor(editor: ICodeEditor, widget: SuggestWidget, model: SuggestModel, accept: (selected: ISelectedSuggestion) => unknown) {
this._disposables.add(model.onDidSuggest(e => { this._disposables.add(model.onDidSuggest(e => {
if (e.completionModel.items.length === 0) { if (e.completionModel.items.length === 0) {

View File

@@ -347,7 +347,7 @@ export class SuggestController implements IEditorContribution {
const { item } = event; const { item } = event;
// //
const tasks: Promise<any>[] = []; const tasks: Promise<unknown>[] = [];
const cts = new CancellationTokenSource(); const cts = new CancellationTokenSource();
// pushing undo stops *before* additional text edits and // pushing undo stops *before* additional text edits and
@@ -662,7 +662,7 @@ export class SuggestController implements IEditorContribution {
// wait for trigger because only then the cancel-event is trustworthy // wait for trigger because only then the cancel-event is trustworthy
const listener: IDisposable[] = []; const listener: IDisposable[] = [];
Event.any<any>(this.model.onDidTrigger, this.model.onDidCancel)(() => { Event.any<unknown>(this.model.onDidTrigger, this.model.onDidCancel)(() => {
// retrigger or cancel -> try to type default text // retrigger or cancel -> try to type default text
dispose(listener); dispose(listener);
fallback(); fallback();
@@ -829,7 +829,7 @@ export class TriggerSuggestAction extends EditorAction {
}); });
} }
run(_accessor: ServicesAccessor, editor: ICodeEditor, args: any): void { run(_accessor: ServicesAccessor, editor: ICodeEditor, args: unknown): void {
const controller = SuggestController.get(editor); const controller = SuggestController.get(editor);
if (!controller) { if (!controller) {

View File

@@ -24,7 +24,7 @@ export enum DiagnosticSeverity {
@es5ClassCompat @es5ClassCompat
export class DiagnosticRelatedInformation { export class DiagnosticRelatedInformation {
static is(thing: any): thing is DiagnosticRelatedInformation { static is(thing: unknown): thing is DiagnosticRelatedInformation {
if (!thing) { if (!thing) {
return false; return false;
} }
@@ -78,7 +78,7 @@ export class Diagnostic {
this.severity = severity; this.severity = severity;
} }
toJSON(): any { toJSON(): { severity: string; message: string; range: Range; source?: string; code?: string | number } {
return { return {
severity: DiagnosticSeverity[this.severity], severity: DiagnosticSeverity[this.severity],
message: this.message, message: this.message,

View File

@@ -12,7 +12,7 @@ import { Range } from './range.js';
@es5ClassCompat @es5ClassCompat
export class Location { export class Location {
static isLocation(thing: any): thing is vscode.Location { static isLocation(thing: unknown): thing is vscode.Location {
if (thing instanceof Location) { if (thing instanceof Location) {
return true; return true;
} }

View File

@@ -14,11 +14,14 @@ export class MarkdownString implements vscode.MarkdownString {
readonly #delegate: BaseMarkdownString; readonly #delegate: BaseMarkdownString;
static isMarkdownString(thing: any): thing is vscode.MarkdownString { static isMarkdownString(thing: unknown): thing is vscode.MarkdownString {
if (thing instanceof MarkdownString) { if (thing instanceof MarkdownString) {
return true; return true;
} }
return thing && thing.appendCodeblock && thing.appendMarkdown && thing.appendText && (thing.value !== undefined); if (!thing || typeof thing !== 'object') {
return false;
}
return (thing as vscode.MarkdownString).appendCodeblock && (thing as vscode.MarkdownString).appendMarkdown && (thing as vscode.MarkdownString).appendText && ((thing as vscode.MarkdownString).value !== undefined);
} }
constructor(value?: string, supportThemeIcons: boolean = false) { constructor(value?: string, supportThemeIcons: boolean = false) {

View File

@@ -17,7 +17,7 @@ export enum NotebookCellKind {
} }
export class NotebookRange { export class NotebookRange {
static isNotebookRange(thing: any): thing is vscode.NotebookRange { static isNotebookRange(thing: unknown): thing is vscode.NotebookRange {
if (thing instanceof NotebookRange) { if (thing instanceof NotebookRange) {
return true; return true;
} }
@@ -104,10 +104,10 @@ export class NotebookCellData {
languageId: string; languageId: string;
mime?: string; mime?: string;
outputs?: vscode.NotebookCellOutput[]; outputs?: vscode.NotebookCellOutput[];
metadata?: Record<string, any>; metadata?: Record<string, unknown>;
executionSummary?: vscode.NotebookCellExecutionSummary; executionSummary?: vscode.NotebookCellExecutionSummary;
constructor(kind: NotebookCellKind, value: string, languageId: string, mime?: string, outputs?: vscode.NotebookCellOutput[], metadata?: Record<string, any>, executionSummary?: vscode.NotebookCellExecutionSummary) { constructor(kind: NotebookCellKind, value: string, languageId: string, mime?: string, outputs?: vscode.NotebookCellOutput[], metadata?: Record<string, unknown>, executionSummary?: vscode.NotebookCellExecutionSummary) {
this.kind = kind; this.kind = kind;
this.value = value; this.value = value;
this.languageId = languageId; this.languageId = languageId;
@@ -123,7 +123,7 @@ export class NotebookCellData {
export class NotebookData { export class NotebookData {
cells: NotebookCellData[]; cells: NotebookCellData[];
metadata?: { [key: string]: any }; metadata?: { [key: string]: unknown };
constructor(cells: NotebookCellData[]) { constructor(cells: NotebookCellData[]) {
this.cells = cells; this.cells = cells;
@@ -133,7 +133,7 @@ export class NotebookData {
@es5ClassCompat @es5ClassCompat
export class NotebookEdit implements vscode.NotebookEdit { export class NotebookEdit implements vscode.NotebookEdit {
static isNotebookCellEdit(thing: any): thing is NotebookEdit { static isNotebookCellEdit(thing: unknown): thing is NotebookEdit {
if (thing instanceof NotebookEdit) { if (thing instanceof NotebookEdit) {
return true; return true;
} }
@@ -156,13 +156,13 @@ export class NotebookEdit implements vscode.NotebookEdit {
return new NotebookEdit(range, []); return new NotebookEdit(range, []);
} }
static updateCellMetadata(index: number, newMetadata: { [key: string]: any }): NotebookEdit { static updateCellMetadata(index: number, newMetadata: { [key: string]: unknown }): NotebookEdit {
const edit = new NotebookEdit(new NotebookRange(index, index), []); const edit = new NotebookEdit(new NotebookRange(index, index), []);
edit.newCellMetadata = newMetadata; edit.newCellMetadata = newMetadata;
return edit; return edit;
} }
static updateNotebookMetadata(newMetadata: { [key: string]: any }): NotebookEdit { static updateNotebookMetadata(newMetadata: { [key: string]: unknown }): NotebookEdit {
const edit = new NotebookEdit(new NotebookRange(0, 0), []); const edit = new NotebookEdit(new NotebookRange(0, 0), []);
edit.newNotebookMetadata = newMetadata; edit.newNotebookMetadata = newMetadata;
return edit; return edit;
@@ -170,8 +170,8 @@ export class NotebookEdit implements vscode.NotebookEdit {
range: NotebookRange; range: NotebookRange;
newCells: NotebookCellData[]; newCells: NotebookCellData[];
newCellMetadata?: { [key: string]: any }; newCellMetadata?: { [key: string]: unknown };
newNotebookMetadata?: { [key: string]: any }; newNotebookMetadata?: { [key: string]: unknown };
constructor(range: NotebookRange, newCells: NotebookCellData[]) { constructor(range: NotebookRange, newCells: NotebookCellData[]) {
this.range = range; this.range = range;
@@ -220,7 +220,7 @@ export class NotebookCellOutputItem {
return new NotebookCellOutputItem(bytes, mime); return new NotebookCellOutputItem(bytes, mime);
} }
static json(value: any, mime: string = 'text/x-json'): NotebookCellOutputItem { static json(value: unknown, mime: string = 'text/x-json'): NotebookCellOutputItem {
const rawStr = JSON.stringify(value, undefined, '\t'); const rawStr = JSON.stringify(value, undefined, '\t');
return NotebookCellOutputItem.text(rawStr, mime); return NotebookCellOutputItem.text(rawStr, mime);
} }
@@ -239,7 +239,7 @@ export class NotebookCellOutputItem {
export class NotebookCellOutput { export class NotebookCellOutput {
static isNotebookCellOutput(candidate: any): candidate is vscode.NotebookCellOutput { static isNotebookCellOutput(candidate: unknown): candidate is vscode.NotebookCellOutput {
if (candidate instanceof NotebookCellOutput) { if (candidate instanceof NotebookCellOutput) {
return true; return true;
} }
@@ -274,12 +274,12 @@ export class NotebookCellOutput {
id: string; id: string;
items: NotebookCellOutputItem[]; items: NotebookCellOutputItem[];
metadata?: Record<string, any>; metadata?: Record<string, unknown>;
constructor( constructor(
items: NotebookCellOutputItem[], items: NotebookCellOutputItem[],
idOrMetadata?: string | Record<string, any>, idOrMetadata?: string | Record<string, unknown>,
metadata?: Record<string, any> metadata?: Record<string, unknown>
) { ) {
this.items = NotebookCellOutput.ensureUniqueMimeTypes(items, true); this.items = NotebookCellOutput.ensureUniqueMimeTypes(items, true);
if (typeof idOrMetadata === 'string') { if (typeof idOrMetadata === 'string') {
@@ -291,4 +291,3 @@ export class NotebookCellOutput {
} }
} }
} }

View File

@@ -38,7 +38,7 @@ export class Position {
return result; return result;
} }
static isPosition(other: any): other is Position { static isPosition(other: unknown): other is Position {
if (!other) { if (!other) {
return false; return false;
} }
@@ -183,7 +183,7 @@ export class Position {
return new Position(line, character); return new Position(line, character);
} }
toJSON(): any { toJSON(): { line: number; character: number } {
return { line: this.line, character: this.character }; return { line: this.line, character: this.character };
} }

View File

@@ -11,15 +11,15 @@ import { Position } from './position.js';
@es5ClassCompat @es5ClassCompat
export class Range { export class Range {
static isRange(thing: any): thing is vscode.Range { static isRange(thing: unknown): thing is vscode.Range {
if (thing instanceof Range) { if (thing instanceof Range) {
return true; return true;
} }
if (!thing) { if (!thing || typeof thing !== 'object') {
return false; return false;
} }
return Position.isPosition((<Range>thing).start) return Position.isPosition((<Range>thing).start)
&& Position.isPosition((<Range>thing.end)); && Position.isPosition((<Range>thing).end);
} }
static of(obj: vscode.Range): Range { static of(obj: vscode.Range): Range {
@@ -149,7 +149,7 @@ export class Range {
return new Range(start, end); return new Range(start, end);
} }
toJSON(): any { toJSON(): unknown {
return [this.start, this.end]; return [this.start, this.end];
} }

View File

@@ -11,11 +11,11 @@ import { getDebugDescriptionOfRange, Range } from './range.js';
@es5ClassCompat @es5ClassCompat
export class Selection extends Range { export class Selection extends Range {
static isSelection(thing: any): thing is Selection { static isSelection(thing: unknown): thing is Selection {
if (thing instanceof Selection) { if (thing instanceof Selection) {
return true; return true;
} }
if (!thing) { if (!thing || typeof thing !== 'object') {
return false; return false;
} }
return Range.isRange(thing) return Range.isRange(thing)

View File

@@ -8,11 +8,11 @@ import { es5ClassCompat } from './es5ClassCompat.js';
@es5ClassCompat @es5ClassCompat
export class SnippetString { export class SnippetString {
static isSnippetString(thing: any): thing is SnippetString { static isSnippetString(thing: unknown): thing is SnippetString {
if (thing instanceof SnippetString) { if (thing instanceof SnippetString) {
return true; return true;
} }
if (!thing) { if (!thing || typeof thing !== 'object') {
return false; return false;
} }
return typeof (<SnippetString>thing).value === 'string'; return typeof (<SnippetString>thing).value === 'string';
@@ -41,7 +41,7 @@ export class SnippetString {
return this; return this;
} }
appendPlaceholder(value: string | ((snippet: SnippetString) => any), number: number = this._tabstop++): SnippetString { appendPlaceholder(value: string | ((snippet: SnippetString) => unknown), number: number = this._tabstop++): SnippetString {
if (typeof value === 'function') { if (typeof value === 'function') {
const nested = new SnippetString(); const nested = new SnippetString();
@@ -74,7 +74,7 @@ export class SnippetString {
return this; return this;
} }
appendVariable(name: string, defaultValue?: string | ((snippet: SnippetString) => any)): SnippetString { appendVariable(name: string, defaultValue?: string | ((snippet: SnippetString) => unknown)): SnippetString {
if (typeof defaultValue === 'function') { if (typeof defaultValue === 'function') {
const nested = new SnippetString(); const nested = new SnippetString();

View File

@@ -10,7 +10,7 @@ import { Range } from './range.js';
export class SnippetTextEdit implements vscode.SnippetTextEdit { export class SnippetTextEdit implements vscode.SnippetTextEdit {
static isSnippetTextEdit(thing: any): thing is SnippetTextEdit { static isSnippetTextEdit(thing: unknown): thing is SnippetTextEdit {
if (thing instanceof SnippetTextEdit) { if (thing instanceof SnippetTextEdit) {
return true; return true;
} }

View File

@@ -76,7 +76,7 @@ export class SymbolInformation {
SymbolInformation.validate(this); SymbolInformation.validate(this);
} }
toJSON(): any { toJSON(): { name: string; kind: string; location: Location; containerName: string | undefined } {
return { return {
name: this.name, name: this.name,
kind: SymbolKind[this.kind], kind: SymbolKind[this.kind],

View File

@@ -16,11 +16,11 @@ export enum EndOfLine {
@es5ClassCompat @es5ClassCompat
export class TextEdit { export class TextEdit {
static isTextEdit(thing: any): thing is TextEdit { static isTextEdit(thing: unknown): thing is TextEdit {
if (thing instanceof TextEdit) { if (thing instanceof TextEdit) {
return true; return true;
} }
if (!thing) { if (!thing || typeof thing !== 'object') {
return false; return false;
} }
return Range.isRange((<TextEdit>thing)) return Range.isRange((<TextEdit>thing))
@@ -87,7 +87,7 @@ export class TextEdit {
this._newText = newText; this._newText = newText;
} }
toJSON(): any { toJSON(): { range: Range; newText: string; newEol: EndOfLine | undefined } {
return { return {
range: this.range, range: this.range,
newText: this.newText, newText: this.newText,

View File

@@ -97,7 +97,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
} }
// --- notebook // --- notebook
private replaceNotebookMetadata(uri: URI, value: Record<string, any>, metadata?: vscode.WorkspaceEditEntryMetadata): void { private replaceNotebookMetadata(uri: URI, value: Record<string, unknown>, metadata?: vscode.WorkspaceEditEntryMetadata): void {
this._edits.push({ _type: FileEditType.Cell, metadata, uri, edit: { editType: CellEditType.DocumentMetadata, metadata: value } }); this._edits.push({ _type: FileEditType.Cell, metadata, uri, edit: { editType: CellEditType.DocumentMetadata, metadata: value } });
} }
@@ -110,7 +110,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
} }
} }
private replaceNotebookCellMetadata(uri: URI, index: number, cellMetadata: Record<string, any>, metadata?: vscode.WorkspaceEditEntryMetadata): void { private replaceNotebookCellMetadata(uri: URI, index: number, cellMetadata: Record<string, unknown>, metadata?: vscode.WorkspaceEditEntryMetadata): void {
this._edits.push({ _type: FileEditType.Cell, metadata, uri, edit: { editType: CellEditType.Metadata, index, metadata: cellMetadata } }); this._edits.push({ _type: FileEditType.Cell, metadata, uri, edit: { editType: CellEditType.Metadata, index, metadata: cellMetadata } });
} }
@@ -215,7 +215,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
return this.entries().length; return this.entries().length;
} }
toJSON(): any { toJSON(): [URI, TextEdit[]][] {
return this.entries(); return this.entries();
} }
} }