Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce unused exports #164938

Closed
joyceerhl opened this issue Oct 28, 2022 · 6 comments
Closed

Reduce unused exports #164938

joyceerhl opened this issue Oct 28, 2022 · 6 comments
Assignees
Labels
debt Code quality issues

Comments

@joyceerhl
Copy link
Contributor

joyceerhl commented Oct 28, 2022

@rebornix and I were wondering if there is any dead code in the VS Code codebase, and one idea was to detect unused exports across the codebase, since unused variables are flagged by the compiler but unused exports are not.

I ran ts-unused-exports on our sources and generated the following list. I've already done a pass to remove some false positives but apologies if several remain.

NB: The primary purpose of this issue is to identify unused functions and classes which aren't being picked up by the compiler because they're exported and which can be safely deleted from our sources to reduce our bundle size. A secondary benefit is to remove unused types and interfaces, e.g. anything which was exported at one point and then ceased to be referenced from other files (which more impacts compile time for dev workflows and pipeline runs, and maybe TS server analysis time, but has no direct impact on bundle size since types are erased).

If you export a type or interface that is not currently actively imported, but is used in the public API of a class that you expose, then it's quite likely that you want to keep that type/interface exported and need not un-export it as part of this issue.

Please feel free to remove your assignment if you find that this isn't valuable.

Git blame Function File
@joyceerhl SelectKernelReturnArgs src/vs/workbench/api/common/extHostNotebookKernels.ts
@jrieken IBreadcrumbsWidgetStyles src/vs/base/browser/ui/breadcrumbs/breadcrumbsWidget.ts
@jrieken InvisibleSizing src/vs/base/browser/ui/grid/grid.ts
@jrieken IResizeEvent src/vs/base/browser/ui/resizable/resizable.ts
@jrieken SplitSizing src/vs/base/browser/ui/splitview/splitview.ts
@jrieken InvisibleSizing src/vs/base/browser/ui/splitview/splitview.ts
@jrieken Revived src/vs/base/common/marshalling.ts
@jrieken mapPager src/vs/base/common/paging.ts
@jrieken ValueCallback src/vs/base/test/common/utils.ts
@jrieken ICommandMenuOptions src/vs/editor/browser/editorExtensions.ts
@jrieken IEditorActionContextMenuOptions src/vs/editor/browser/editorExtensions.ts
@jrieken _CSS_MAP src/vs/editor/browser/services/abstractCodeEditorService.ts
@jrieken IGetWordAtTextConfig src/vs/editor/common/core/wordHelper.ts
@jrieken CodeLensCache src/vs/editor/contrib/codelens/browser/codeLensCache.ts
@jrieken IDecorationIdCallback src/vs/editor/contrib/codelens/browser/codelensWidget.ts
@jrieken MarkerCoordinate src/vs/editor/contrib/gotoError/browser/markerNavigationService.ts
@jrieken ctxHasSymbols src/vs/editor/contrib/gotoSymbol/browser/symbolNavigation.ts
@jrieken ctxReferenceSearchVisible src/vs/editor/contrib/gotoSymbol/browser/peek/referencesController.ts
@jrieken SelectionEvent src/vs/editor/contrib/gotoSymbol/browser/peek/referencesWidget.ts
@jrieken RenameInputFieldResult src/vs/editor/contrib/rename/browser/renameInputField.ts
@jrieken Token src/vs/editor/contrib/snippet/browser/snippetParser.ts
@jrieken TransformableMarker src/vs/editor/contrib/snippet/browser/snippetParser.ts
@jrieken OneSnippet src/vs/editor/contrib/snippet/browser/snippetSession.ts
@jrieken ISnippetSessionInsertOptions src/vs/editor/contrib/snippet/browser/snippetSession.ts
@jrieken IReadClipboardText src/vs/editor/contrib/snippet/browser/snippetVariables.ts
@jrieken ICompletionStats src/vs/editor/contrib/suggest/browser/completionModel.ts
@jrieken MemItem src/vs/editor/contrib/suggest/browser/suggestMemory.ts
@jrieken MemMode src/vs/editor/contrib/suggest/browser/suggestMemory.ts
@jrieken SuggestMemoryService src/vs/editor/contrib/suggest/browser/suggestMemory.ts
@jrieken SuggestContentWidget src/vs/editor/contrib/suggest/browser/suggestWidget.ts
@jrieken ISuggestionTemplateData src/vs/editor/contrib/suggest/browser/suggestWidgetRenderer.ts
@jrieken ViewZoneDelegate src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts
@jrieken OverlayWidgetDelegate src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts
@jrieken createDiffNavigator src/vs/editor/standalone/browser/standaloneEditor.ts
@jrieken getModelMarkers src/vs/editor/standalone/browser/standaloneEditor.ts
@jrieken getModel src/vs/editor/standalone/browser/standaloneEditor.ts
@jrieken onDidChangeModelLanguage src/vs/editor/standalone/browser/standaloneEditor.ts
@jrieken register src/vs/editor/standalone/browser/standaloneLanguages.ts
@jrieken onLanguage src/vs/editor/standalone/browser/standaloneLanguages.ts
@jrieken setLanguageConfiguration src/vs/editor/standalone/browser/standaloneLanguages.ts
@jrieken IColors src/vs/editor/standalone/common/standaloneTheme.ts
@jrieken ILoadStatus src/vs/editor/standalone/common/monarch/monarchLexer.ts
@jrieken ICommandActionToggleInfo src/vs/platform/action/common/action.ts
@jrieken IDropdownWithDefaultActionViewItemOptions src/vs/platform/actions/browser/menuEntryActionViewItem.ts
@jrieken DropdownWithDefaultActionViewItem src/vs/platform/actions/browser/menuEntryActionViewItem.ts
@jrieken IWorkbenchToolBarOptions src/vs/platform/actions/browser/toolbar.ts
@jrieken IToolBarRenderOptions src/vs/platform/actions/browser/toolbar.ts
@jrieken IMenuWorkbenchToolBarOptions src/vs/platform/actions/browser/toolbar.ts
@jrieken IMenuRegistryChangeEvent src/vs/platform/actions/common/actions.ts
@jrieken IMenuRegistry src/vs/platform/actions/common/actions.ts
@jrieken ICommand src/vs/platform/commands/common/commands.ts
@jrieken ICommandRegistry src/vs/platform/commands/common/commands.ts
@jrieken AbstractContextKeyService src/vs/platform/contextkey/browser/contextKeyService.ts
@jrieken Node src/vs/platform/instantiation/common/graph.ts
@jrieken IV8CallFrame src/vs/platform/profiling/common/profiling.ts
@jrieken IComputedNode src/vs/platform/profiling/common/profilingModel.ts
@jrieken ISourceLocation src/vs/platform/profiling/common/profilingModel.ts
@jrieken CdpPositionTickInfo src/vs/platform/profiling/common/profilingModel.ts
@jrieken INode src/vs/platform/profiling/common/profilingModel.ts
@jrieken ILocation src/vs/platform/profiling/common/profilingModel.ts
@jrieken IAnnotationLocation src/vs/platform/profiling/common/profilingModel.ts
@jrieken IProfileNode src/vs/platform/profiling/common/profilingModel.ts
@jrieken ICpuProfileRaw src/vs/platform/profiling/common/profilingModel.ts
@jrieken SampleData src/vs/platform/profiling/common/profilingTelemetrySpec.ts
@jrieken create src/vs/platform/profiling/electron-sandbox/profileAnalysisWorker.ts
@jrieken IScriptUrlClassifier src/vs/platform/profiling/electron-sandbox/profileAnalysisWorkerService.ts
@jrieken CategoryAnalysis src/vs/platform/profiling/electron-sandbox/profileAnalysisWorkerService.ts
@jrieken IBreadcrumbsWidgetStyleOverrides src/vs/platform/theme/common/styler.ts
@jrieken defaultBreadcrumbsStyles src/vs/platform/theme/common/styler.ts
@jrieken Idle src/vs/platform/update/common/update.ts
@jrieken CheckingForUpdates src/vs/platform/update/common/update.ts
@jrieken Downloading src/vs/platform/update/common/update.ts
@jrieken Downloaded src/vs/platform/update/common/update.ts
@jrieken Updating src/vs/platform/update/common/update.ts
@jrieken Ready src/vs/platform/update/common/update.ts
@jrieken ExtHostDebugConsole src/vs/workbench/api/common/extHostDebugService.ts
@jrieken IExtHostDocumentsAndEditorsDelta src/vs/workbench/api/common/extHostDocumentsAndEditors.ts
@jrieken Tunnel src/vs/workbench/api/common/extHostTunnelService.ts
@jrieken IConsolePatchFn src/vs/workbench/api/common/extensionHostMain.ts
@jrieken MarketplaceExtension src/vs/workbench/browser/web.api.ts
@jrieken BreadcrumbsService src/vs/workbench/browser/parts/editor/breadcrumbs.ts
@jrieken SelectEvent src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
@jrieken FileSorter src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts
@jrieken CheckedStates src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPreview.ts
@jrieken ICheckable src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditTree.ts
@jrieken DocumentSymbolItem src/vs/workbench/contrib/codeEditor/browser/outline/documentSymbolsTree.ts
@jrieken INotebookRawData src/vs/workbench/contrib/notebook/common/notebookService.ts
@jrieken createTestNotebookEditor src/vs/workbench/contrib/notebook/test/browser/testNotebookEditor.ts
@jrieken SearchEditorData src/vs/workbench/contrib/searchEditor/browser/searchEditorModel.ts
@jrieken extractSearchQueryFromModel src/vs/workbench/contrib/searchEditor/browser/searchEditorSerialization.ts
@jrieken extractSearchQueryFromLines src/vs/workbench/contrib/searchEditor/browser/searchEditorSerialization.ts
@jrieken ISimpleModel src/vs/workbench/contrib/snippets/browser/snippetsService.ts
@jrieken validateTerminalName src/vs/workbench/contrib/terminal/browser/terminalActions.ts
@jrieken allWalkthroughsHiddenContext src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
@jrieken IExtensionDevOptions src/vs/workbench/services/extensions/common/extensionDevOptions.ts
@jrieken ILanguageStatusProvider src/vs/workbench/services/languageStatus/common/languageStatusService.ts
@jrieken IMemoryInfo src/vs/workbench/services/timer/browser/timerService.ts
@lramos15 Filters src/vs/platform/assignment/common/assignment.ts
@lramos15 AssignmentService src/vs/platform/assignment/common/assignmentService.ts
@lramos15 IWalkthroughStep src/vs/platform/extensions/common/extensions.ts
@lramos15 IStartEntry src/vs/platform/extensions/common/extensions.ts
@lramos15 IPropertyData src/vs/platform/telemetry/common/gdprTypings.ts
@lramos15 StrictPropertyChecker src/vs/platform/telemetry/common/gdprTypings.ts
@lramos15 StrictPropertyCheckError src/vs/platform/telemetry/common/gdprTypings.ts
@lramos15 Properties src/vs/platform/telemetry/common/telemetryUtils.ts
@lramos15 Measurements src/vs/platform/telemetry/common/telemetryUtils.ts
@lramos15 ExtHostTelemetryLogger src/vs/workbench/api/common/extHostTelemetry.ts
@lramos15 EditorReplacement src/vs/workbench/browser/parts/editor/editorGroupView.ts
@lramos15 IResourceMergeEditorInputSide src/vs/workbench/common/editor.ts
@lramos15 IMatchOptions src/vs/workbench/common/editor/editorGroupModel.ts
@lramos15 TimelineExcludeSources src/vs/workbench/contrib/timeline/browser/timelinePane.ts
@lramos15 embedderIdentifierContext src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
@lramos15 IWelcomePageStartEntry src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts
@lramos15 HasMultipleNewFileEntries src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts
@lramos15 walkthroughMetadataConfigurationKey src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts
@lramos15 WalkthroughMetaDataType src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts
@lramos15 IWalkthrough src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts
@lramos15 IWalkthroughLoose src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts
@lramos15 IWalkthroughStep src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts
@lramos15 WalkthroughsService src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.ts
@lramos15 BuiltinGettingStartedStep src/vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent.ts
@lramos15 BuiltinGettingStartedCategory src/vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent.ts
@lramos15 BuiltinGettingStartedStartEntry src/vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent.ts
@lramos15 OtherTestEditor src/vs/workbench/test/browser/parts/editor/editorPane.test.ts
@lszomoru WorkspaceTrustRequestButton src/vs/platform/workspace/common/workspaceTrust.ts
@lszomoru ExtHostSCMInputBox src/vs/workbench/api/common/extHostSCM.ts
@lszomoru IExtHostTimeline src/vs/workbench/api/common/extHostTimeline.ts
@lszomoru maxSize src/vs/workbench/contrib/sash/browser/sash.ts
@lszomoru SCMActionButton src/vs/workbench/contrib/scm/browser/scmViewPane.ts
@lszomoru TimelineFollowActiveEditorContext src/vs/workbench/contrib/timeline/browser/timelinePane.ts
@lszomoru TimelineElementTemplate src/vs/workbench/contrib/timeline/browser/timelinePane.ts
@lszomoru TimelineIdentityProvider src/vs/workbench/contrib/timeline/browser/timelinePane.ts
@lszomoru TimelineKeyboardNavigationLabelProvider src/vs/workbench/contrib/timeline/browser/timelinePane.ts
@lszomoru TimelineListVirtualDelegate src/vs/workbench/contrib/timeline/browser/timelinePane.ts
@lszomoru toKey src/vs/workbench/contrib/timeline/common/timeline.ts
@lszomoru TimelineSource src/vs/workbench/contrib/timeline/common/timeline.ts
@lszomoru WorkspaceTrustRequestService src/vs/workbench/services/workspaces/common/workspaceTrust.ts
@jrieken
Copy link
Member

jrieken commented Oct 31, 2022

Let's pause a moment and re-consider all the interface and type types. They aren't transpiled to JavaScript and I believe won't have an impact on code size

@jrieken
Copy link
Member

jrieken commented Oct 31, 2022

So, suggestion 1 is to rerun with the allowUnusedTypes option but I also doubt the correctness of the tool. Randomly looking at ICommandActionToggleInfo which is exported. Yes, nobody directly imports it but it is "public API surface" via ICommandAction#toggled. I believe that's a dangerous false-positive and will only work because of TypeScript's auto-export behaviours but not really a be code improvement

joaomoreno added a commit that referenced this issue Oct 31, 2022
joaomoreno added a commit that referenced this issue Oct 31, 2022
@alexdima
Copy link
Member

I also have expressed some concerns in #164934 (comment)

@joyceerhl
Copy link
Contributor Author

Quick clarification here: the primary purpose of this issue is to identify unused functions and classes which aren't being picked up by the compiler because they're exported and which can be safely deleted from our sources to reduce our bundle size. A secondary benefit is to remove unused types and interfaces, e.g. anything which was exported at one point and then ceased to be referenced from other files (which more impacts compile time for dev workflows and pipeline runs, and maybe TS server analysis time, but has no direct impact on bundle size since types are erased).

If you export a type or interface that is not currently actively imported, but is used in the public API of a class that you expose, then it's quite likely that you want to keep that type/interface exported and should not un-export it as part of this issue.

As @jrieken pointed out there are several such false positives from this tool. From talking to @rebornix we can achieve at least the primary purpose of this issue a different way, e.g. by adapting the existing tree shaking tooling we have for Monaco to flag dead code in microsoft/vscode e.g. at the start of each debt week. I opened #165092 to track that.

@lramos15 lramos15 removed their assignment Nov 4, 2022
@lszomoru lszomoru added the debt Code quality issues label Dec 5, 2022
@lszomoru
Copy link
Member

lszomoru commented Dec 5, 2022

@joyceerhl, are we still pursuing this effort?

@joaomoreno joaomoreno removed their assignment Dec 5, 2022
@lszomoru lszomoru removed their assignment Jan 2, 2023
@jrieken jrieken closed this as completed Nov 29, 2023
@jrieken
Copy link
Member

jrieken commented Nov 29, 2023

Closing this without further action

@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debt Code quality issues
Projects
None yet
Development

No branches or pull requests

6 participants