Skip to content

Commit

Permalink
Refactor code to remove unused JSDoc types (#24300)
Browse files Browse the repository at this point in the history
Fixes #24077

Removes redundant type annotations from JSDocs in TypeScript files where
the type is already inferred by TypeScript.

For example:

![image](https://github.com/user-attachments/assets/9ee1f0b6-f36f-4f4f-81dc-5178d46808cb)

Here I removed JSDoc types but I still kept all the useful information. 
I tried to be on the liberal side to avoid removing any comments that
provide useful context or clarify behavior. If I missed any or if more
can be removed, I’m happy to go over it again.

Additionally, if this issue only applies to a specific folder or scope,
please let me know so I can make the necessary adjustments.
  • Loading branch information
brokoli777 authored Oct 14, 2024
1 parent 9be9308 commit c5a8e4f
Show file tree
Hide file tree
Showing 37 changed files with 5 additions and 192 deletions.
1 change: 0 additions & 1 deletion pythonExtensionApi/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export interface PythonExtension {

/**
* Gets the path to the debugger package used by the extension.
* @returns {Promise<string>}
*/
getDebuggerPackagePath(): Promise<string | undefined>;
};
Expand Down
24 changes: 1 addition & 23 deletions src/client/activation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,14 @@ import { PythonEnvironment } from '../pythonEnvironments/info';
export const IExtensionActivationManager = Symbol('IExtensionActivationManager');
/**
* Responsible for activation of extension.
*
* @export
* @interface IExtensionActivationManager
* @extends {IDisposable}
*/
export interface IExtensionActivationManager extends IDisposable {
/**
* Method invoked when extension activates (invoked once).
*
* @returns {Promise<void>}
* @memberof IExtensionActivationManager
*/
// Method invoked when extension activates (invoked once).
activate(startupStopWatch: StopWatch): Promise<void>;
/**
* Method invoked when a workspace is loaded.
* This is where we place initialization scripts for each workspace.
* (e.g. if we need to run code for each workspace, then this is where that happens).
*
* @param {Resource} resource
* @returns {Promise<void>}
* @memberof IExtensionActivationManager
*/
activateWorkspace(resource: Resource): Promise<void>;
}
Expand All @@ -43,8 +30,6 @@ export const IExtensionActivationService = Symbol('IExtensionActivationService')
* invoked for every workspace folder (in multi-root workspace folders) during the activation of the extension.
* This is a great hook for extension activation code, i.e. you don't need to modify
* the `extension.ts` file to invoke some code when extension gets activated.
* @export
* @interface IExtensionActivationService
*/
export interface IExtensionActivationService {
supportedWorkspaceTypes: { untrustedWorkspace: boolean; virtualWorkspace: boolean };
Expand Down Expand Up @@ -100,8 +85,6 @@ export interface ILanguageServerProxy extends IDisposable {
* Sends a request to LS so as to load other extensions.
* This is used as a plugin loader mechanism.
* Anyone (such as intellicode) wanting to interact with LS, needs to send this request to LS.
* @param {{}} [args]
* @memberof ILanguageServerProxy
*/
loadExtension(args?: unknown): void;
}
Expand All @@ -110,9 +93,6 @@ export const ILanguageServerOutputChannel = Symbol('ILanguageServerOutputChannel
export interface ILanguageServerOutputChannel {
/**
* Creates output channel if necessary and returns it
*
* @type {ILogOutputChannel}
* @memberof ILanguageServerOutputChannel
*/
readonly channel: ILogOutputChannel;
}
Expand All @@ -123,8 +103,6 @@ export const IExtensionSingleActivationService = Symbol('IExtensionSingleActivat
* invoked during the activation of the extension.
* This is a great hook for extension activation code, i.e. you don't need to modify
* the `extension.ts` file to invoke some code when extension gets activated.
* @export
* @interface IExtensionSingleActivationService
*/
export interface IExtensionSingleActivationService {
supportedWorkspaceTypes: { untrustedWorkspace: boolean; virtualWorkspace: boolean };
Expand Down
1 change: 0 additions & 1 deletion src/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export function buildApi(
* @param {Resource} [resource] A resource for which the setting is asked for.
* * When no resource is provided, the setting scoped to the first workspace folder is returned.
* * If no folder is present, it returns the global setting.
* @returns {({ execCommand: string[] | undefined })}
*/
getExecutionDetails(
resource?: Resource,
Expand Down
1 change: 0 additions & 1 deletion src/client/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export interface PythonExtension {

/**
* Gets the path to the debugger package used by the extension.
* @returns {Promise<string>}
*/
getDebuggerPackagePath(): Promise<string | undefined>;
};
Expand Down
5 changes: 0 additions & 5 deletions src/client/application/diagnostics/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ export abstract class BaseDiagnosticsService implements IDiagnosticsService, IDi
/**
* Returns a key used to keep track of whether a diagnostic was handled or not.
* So as to prevent handling/displaying messages multiple times for the same diagnostic.
*
* @protected
* @param {IDiagnostic} diagnostic
* @returns {string}
* @memberof BaseDiagnosticsService
*/
protected getDiagnosticsKey(diagnostic: IDiagnostic): string {
if (diagnostic.scope === DiagnosticScope.Global) {
Expand Down
2 changes: 0 additions & 2 deletions src/client/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export interface IApplicationDiagnostics {
/**
* Perform pre-extension activation health checks.
* E.g. validate user environment, etc.
* @returns {Promise<void>}
* @memberof IApplicationDiagnostics
*/
performPreStartupHealthCheck(resource: Resource): Promise<void>;
register(): void;
Expand Down
4 changes: 0 additions & 4 deletions src/client/common/application/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export type CommandsWithoutArgs = keyof ICommandNameWithoutArgumentTypeMapping;
/**
* Mapping between commands and list or arguments.
* These commands do NOT have any arguments.
* @interface ICommandNameWithoutArgumentTypeMapping
*/
interface ICommandNameWithoutArgumentTypeMapping {
[Commands.InstallPythonOnMac]: [];
Expand Down Expand Up @@ -52,9 +51,6 @@ export type AllCommands = keyof ICommandNameArgumentTypeMapping;
/**
* Mapping between commands and list of arguments.
* Used to provide strong typing for command & args.
* @export
* @interface ICommandNameArgumentTypeMapping
* @extends {ICommandNameWithoutArgumentTypeMapping}
*/
export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgumentTypeMapping {
[Commands.Create_Environment]: [CreateEnvironmentOptions];
Expand Down
3 changes: 0 additions & 3 deletions src/client/common/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,6 @@ export interface IWorkspaceService {

/**
* Generate a key that's unique to the workspace folder (could be fsPath).
* @param {(Uri | undefined)} resource
* @returns {string}
* @memberof IWorkspaceService
*/
getWorkspaceFolderIdentifier(resource: Uri | undefined, defaultValue?: string): string;
/**
Expand Down
11 changes: 0 additions & 11 deletions src/client/common/cancellation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ export class CancellationError extends Error {
}
/**
* Create a promise that will either resolve with a default value or reject when the token is cancelled.
*
* @export
* @template T
* @param {({ defaultValue: T; token: CancellationToken; cancelAction: 'reject' | 'resolve' })} options
* @returns {Promise<T>}
*/
export function createPromiseFromCancellation<T>(options: {
defaultValue: T;
Expand Down Expand Up @@ -50,10 +45,6 @@ export function createPromiseFromCancellation<T>(options: {

/**
* Create a single unified cancellation token that wraps multiple cancellation tokens.
*
* @export
* @param {(...(CancellationToken | undefined)[])} tokens
* @returns {CancellationToken}
*/
export function wrapCancellationTokens(...tokens: (CancellationToken | undefined)[]): CancellationToken {
const wrappedCancellantionToken = new CancellationTokenSource();
Expand Down Expand Up @@ -117,15 +108,13 @@ export namespace Cancellation {

/**
* isCanceled returns a boolean indicating if the cancel token has been canceled.
* @param cancelToken
*/
export function isCanceled(cancelToken?: CancellationToken): boolean {
return cancelToken ? cancelToken.isCancellationRequested : false;
}

/**
* throws a CancellationError if the token is canceled.
* @param cancelToken
*/
export function throwIfCanceled(cancelToken?: CancellationToken): void {
if (isCanceled(cancelToken)) {
Expand Down
2 changes: 0 additions & 2 deletions src/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ export function isTestExecution(): boolean {
/**
* Whether we're running unit tests (*.unit.test.ts).
* These tests have a special meaning, they run fast.
* @export
* @returns {boolean}
*/
export function isUnitTestExecution(): boolean {
return process.env.VSC_PYTHON_UNIT_TEST === '1';
Expand Down
1 change: 0 additions & 1 deletion src/client/common/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ declare interface String {
/**
* Appropriately formats a string so it can be used as an argument for a command in a shell.
* E.g. if an argument contains a space, then it will be enclosed within double quotes.
* @param {String} value.
*/
String.prototype.toCommandArgumentForPythonExt = function (this: string): string {
if (!this) {
Expand Down
5 changes: 0 additions & 5 deletions src/client/common/installer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ export interface IModuleInstaller {
* If a cancellation token is provided, then a cancellable progress message is dispalyed.
* At this point, this method would resolve only after the module has been successfully installed.
* If cancellation token is not provided, its not guaranteed that module installation has completed.
* @param {string} name
* @param {InterpreterUri} [resource]
* @param {CancellationToken} [cancel]
* @returns {Promise<void>}
* @memberof IModuleInstaller
*/
installModule(
productOrModuleName: Product | string,
Expand Down
4 changes: 0 additions & 4 deletions src/client/common/terminal/shellDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export class ShellDetector {
* 3. Try to identify the type of the shell based on the user environment (OS).
* 4. If all else fail, use defaults hardcoded (cmd for windows, bash for linux & mac).
* More information here: https://github.com/microsoft/vscode/issues/74233#issuecomment-497527337
*
* @param {Terminal} [terminal]
* @returns {TerminalShellType}
* @memberof TerminalHelper
*/
public identifyTerminalShell(terminal?: Terminal): TerminalShellType {
let shell: TerminalShellType | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import { BaseShellDetector } from './baseShellDetector';

/**
* Identifies the shell based on the user settings.
*
* @export
* @class SettingsShellDetector
* @extends {BaseShellDetector}
*/
@injectable()
export class SettingsShellDetector extends BaseShellDetector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import { BaseShellDetector } from './baseShellDetector';

/**
* Identifies the shell, based on the display name of the terminal.
*
* @export
* @class TerminalNameShellDetector
* @extends {BaseShellDetector}
*/
@injectable()
export class TerminalNameShellDetector extends BaseShellDetector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import { BaseShellDetector } from './baseShellDetector';

/**
* Identifies the shell based on the users environment (env variables).
*
* @export
* @class UserEnvironmentShellDetector
* @extends {BaseShellDetector}
*/
@injectable()
export class UserEnvironmentShellDetector extends BaseShellDetector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import { BaseShellDetector } from './baseShellDetector';

/**
* Identifies the shell, based on the VSC Environment API.
*
* @export
* @class VSCEnvironmentShellDetector
* @extends {BaseShellDetector}
*/
export class VSCEnvironmentShellDetector extends BaseShellDetector {
constructor(@inject(IApplicationEnvironment) private readonly appEnv: IApplicationEnvironment) {
Expand Down
5 changes: 0 additions & 5 deletions src/client/common/terminal/syncTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ class ExecutionState implements Disposable {
* - Send text to a terminal that executes our python file, passing in the original text as args
* - The pthon file will execute the commands as a subprocess
* - At the end of the execution a file is created to singal completion.
*
* @export
* @class SynchronousTerminalService
* @implements {ITerminalService}
* @implements {Disposable}
*/
export class SynchronousTerminalService implements ITerminalService, Disposable {
private readonly disposables: Disposable[] = [];
Expand Down
16 changes: 1 addition & 15 deletions src/client/common/terminal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ export interface ITerminalServiceFactory {
/**
* Gets a terminal service.
* If one exists with the same information, that is returned else a new one is created.
*
* @param {TerminalCreationOptions}
* @returns {ITerminalService}
* @memberof ITerminalServiceFactory
*/
getTerminalService(options: TerminalCreationOptions & { newTerminalPerFile?: boolean }): ITerminalService;
createTerminalService(resource?: Uri, title?: string): ITerminalService;
Expand Down Expand Up @@ -132,11 +128,7 @@ export type TerminalActivationOptions = {
resource?: Resource;
preserveFocus?: boolean;
interpreter?: PythonEnvironment;
/**
* When sending commands to the terminal, do not display the terminal.
*
* @type {boolean}
*/
// When sending commands to the terminal, do not display the terminal.
hideFromUser?: boolean;
};
export interface ITerminalActivator {
Expand Down Expand Up @@ -170,16 +162,10 @@ export const IShellDetector = Symbol('IShellDetector');
/**
* Used to identify a shell.
* Each implemenetion will provide a unique way of identifying the shell.
*
* @export
* @interface IShellDetector
*/
export interface IShellDetector {
/**
* Classes with higher priorities will be used first when identifying the shell.
*
* @type {number}
* @memberof IShellDetector
*/
readonly priority: number;
identify(telemetryProperties: ShellIdentificationTelemetry, terminal?: Terminal): TerminalShellType | undefined;
Expand Down
6 changes: 0 additions & 6 deletions src/client/common/utils/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,6 @@ export async function flattenIterable<T>(iterableItem: AsyncIterable<T>): Promis

/**
* Wait for a condition to be fulfilled within a timeout.
*
* @export
* @param {() => Promise<boolean>} condition
* @param {number} timeoutMs
* @param {string} errorMessage
* @returns {Promise<void>}
*/
export async function waitForCondition(
condition: () => Promise<boolean>,
Expand Down
6 changes: 1 addition & 5 deletions src/client/common/utils/cacheUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@

const globalCacheStore = new Map<string, { expiry: number; data: any }>();

/**
* Gets a cache store to be used to store return values of methods or any other.
*
* @returns
*/
// Gets a cache store to be used to store return values of methods or any other.
export function getGlobalCacheStore() {
return globalCacheStore;
}
Expand Down
7 changes: 0 additions & 7 deletions src/client/common/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? nev
* Checking whether something is a Resource (Uri/undefined).
* Using `instanceof Uri` doesn't always work as the object is not an instance of Uri (at least not in tests).
* That's why VSC too has a helper method `URI.isUri` (though not public).
*
* @export
* @param {InterpreterUri} [resource]
* @returns {resource is Resource}
*/
export function isResource(resource?: InterpreterUri): resource is Resource {
if (!resource) {
Expand All @@ -44,9 +40,6 @@ export function isResource(resource?: InterpreterUri): resource is Resource {
* Checking whether something is a Uri.
* Using `instanceof Uri` doesn't always work as the object is not an instance of Uri (at least not in tests).
* That's why VSC too has a helper method `URI.isUri` (though not public).
*
* @param {InterpreterUri} [resource]
* @returns {resource is Uri}
*/

function isUri(resource?: Uri | any): resource is Uri {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import { DebuggerTypeName } from '../../constants';
/**
* This class is responsible for automatically attaching the debugger to any
* child processes launched. I.e. this is the class responsible for multi-proc debugging.
* @export
* @class ChildProcessAttachEventHandler
* @implements {IDebugSessionEventHandlers}
*/
@injectable()
export class ChildProcessAttachEventHandler implements IDebugSessionEventHandlers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ import { getWorkspaceFolders } from '../../../common/vscodeApis/workspaceApis';
/**
* This class is responsible for attaching the debugger to any
* child processes launched. I.e. this is the class responsible for multi-proc debugging.
* @export
* @class ChildProcessAttachEventHandler
* @implements {IChildProcessAttachService}
*/
@injectable()
export class ChildProcessAttachService implements IChildProcessAttachService {
Expand Down
1 change: 0 additions & 1 deletion src/client/deprecatedProposedApiTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export interface DeprecatedProposedAPI {
* @param {Resource} [resource] A resource for which the setting is asked for.
* * When no resource is provided, the setting scoped to the first workspace folder is returned.
* * If no folder is present, it returns the global setting.
* @returns {({ execCommand: string[] | undefined })}
*/
getExecutionDetails(
resource?: Resource,
Expand Down
3 changes: 0 additions & 3 deletions src/client/interpreter/autoSelection/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ export const IInterpreterAutoSelectionProxyService = Symbol('IInterpreterAutoSel
* However, the class that reads python Path, must first give preference to selected interpreter.
* But all classes everywhere make use of python settings!
* Solution - Use a proxy that does nothing first, but later the real instance is injected.
*
* @export
* @interface IInterpreterAutoSelectionProxyService
*/
export interface IInterpreterAutoSelectionProxyService {
readonly onDidChangeAutoSelectedInterpreter: Event<void>;
Expand Down
Loading

0 comments on commit c5a8e4f

Please sign in to comment.