-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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 #164934
Comments
Just because something isn't used by anyone, it doesn't mean it should not be exported, since someone might need to import it. Especially types that are referenced in exported public methods should IMHO remain exported. Not so long ago, TS would even give a compile error if a public exported member was referencing a non-exported type. For example, // callback is inlined, there's no need to name its type
monitor.startMonitoring(..., (event: PointerEvent) => { /* do something */ }, ...); But a user of this class might want to write this kind of code: // callback is not inlined, maybe its type needs to be referred explicitly
const moveCallback: IPointerMoveCallback = (event: PointerEvent) => { /* do something */ };
monitor.startMonitoring(..., moveCallback, ...); Another example, this._register(textArea.onCompositionStart((e) => { /* do something */ })); But a user might want to extract the event handler to a method: this._register(textArea.onCompositionStart((e) => this._onCompositionStart(e)));
// ...
private _onCompositionStart(e: ICompositionStartEvent) { /* do something */ } A third example, const guessedIndentation = guessIndentation(textBuffer, options.tabSize, options.insertSpaces); But a user might want to extract the code to a method and they would want to use the type. |
* Fixes #164934: Only export symbols that are needed * `KeyMod` is referenced by `monaco.d.ts`
@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. From a quick sanity check, several of these are indeed not used outside of the file they are declared in and do not need to be exported. Please feel free to close if you find that this isn't valuable.IPointerMoveCallback
IOnStopCallback
AbstractScrollbarOptions
AbstractScrollableElement
KeyLabelProvider
ModifierLabelProvider
ScrollState
ISmoothScrollPosition
IScrollableOptions
IAnimation
IRequestHandlerFactory
create
NodeSocketCloseEvent
WebSocketCloseEvent
SocketTimeoutEvent
RequestType
ResponseType
IChannelServer
IRoutingChannelClient
RequestInitiator
logWithColors
IMouseWheelEvent
Ctor
beginTrackingDisposables
endTrackingDisposables
beginLoggingFS
endLoggingFS
testRepeat
Token
editor
initialize
ICommandKeybindingsOptions
CommandImplementation
IContributionCommandOptions
EditorControllerCommand
EditorActionImplementation
ISerializedFontInfo
ISettingsReader
shadowCaretRangeFromPoint
ClipboardStoredMetadata
ICompositionStartEvent
ModelTransientSettingWatcher
RefCountedStyleSheet
IMouseDispatchData
ViewOverlays
ViewOverlayLine
EventCallback
AbstractLineHighlightOverlay
IMinimapModel
RevealTarget
CharacterMap
MultipleCharacterMap
cachedStringRepeat
IEditorZoom
CursorPosition
IDiffComputerResult
Uint8Matrix
EditorModesRegistry
IReducedTokenizationSupport
ThemeTrieElement
IGuessedIndentation
LONG_LINE_BOUNDARY
IDecorationsTreesHost
DidChangeDecorationsEmitter
DidChangeContentEmitter
KeyMod
IRawModelData
MirrorModel
IForeignModuleFactory
create
ID_EDITOR_WORKER_SERVICE
DocumentSemanticTokensResult
IResolvedLanguage
EditStackPastFutureElements
ILineSequence
ModelSemanticColoring
SemanticTokensProviderStylingConstants
SparseLineTokens
RenderWhitespace
CharacterMappingConstants
RenderLineOutput
IDecorationsViewportData
ColorHover
IPreflightDataSupported
IPreflightDataUnsupported
TestFindController
ClickLinkOptions
HoverResult
MarkerHover
InlineCompletionsHover
IGlobalEditorOptions
StandaloneCodeEditor
create
onDidCreateEditor
onDidCreateDiffEditor
getEditors
getDiffEditors
createDiffEditor
IDiffNavigatorOptions
ICommandDescriptor
addCommand
addEditorAction
IKeybindingRule
addKeybindingRule
addKeybindingRules
createModel
setModelLanguage
setModelMarkers
removeAllMarkers
onDidChangeMarkers
getModels
onDidCreateModel
onWillDisposeModel
createWebWorker
colorizeElement
colorize
colorizeModelLine
tokenize
remeasureFonts
registerCommand
getLanguages
EncodedTokenizationSupportAdapter
TokensProviderFactory
setColorMap
registerTokensProviderFactory
setTokensProvider
setMonarchTokensProvider
registerReferenceProvider
registerRenameProvider
registerSignatureHelpProvider
registerHoverProvider
registerDocumentSymbolProvider
registerDocumentHighlightProvider
registerLinkedEditingRangeProvider
registerDefinitionProvider
registerImplementationProvider
registerTypeDefinitionProvider
registerCodeLensProvider
registerCodeActionProvider
registerDocumentFormattingEditProvider
registerDocumentRangeFormattingEditProvider
registerOnTypeFormattingEditProvider
registerLinkProvider
registerCompletionItemProvider
registerColorProvider
registerFoldingRangeProvider
registerDeclarationProvider
registerSelectionRangeProvider
registerDocumentSemanticTokensProvider
registerDocumentRangeSemanticTokensProvider
registerInlineCompletionsProvider
registerInlayHintsProvider
CodeActionProvider
CodeActionProviderMetadata
IKeybindingRule
EditorScopedQuickInputService
IShortMonarchLanguageRule1
IShortMonarchLanguageRule2
IExpandedMonarchLanguageRule
IMonarchLanguageRule
IShortMonarchLanguageAction
IExpandedMonarchLanguageAction
IMonarchLanguageAction
TestCodeEditorCreationOptions
createSingleEditOp
createSingleEditOp
MockTextAreaWrapper
testTextBufferFactory
generateRandomEdits
generateSequentialInserts
generateRandomReplaces
IContextKeyExpression
ContextKeyFalseExpr
ContextKeyTrueExpr
ContextKeyNotRegexExpr
ITranslation
IWindowsKeyMapping
ILinuxKeyMapping
ILinuxKeyboardMapping
IMacKeyMapping
IMacKeyboardMapping
IWebSocketCloseEvent
IWebSocket
defaultWebSocketFactory
AuthRequest
OKMessage
ConnectionLostEvent
ReconnectionRunningEvent
ConnectionGainEvent
ReconnectionPermanentFailureEvent
ExtensionHostPersistentConnection
URIDescriptor
fontStylePattern
BaseTunnelService
RemoteExtensionHostAgentServer
IExtensionsManagementProcessInitData
printTime
spawnCli
createServer
NoneServerConnectionToken
OptionalServerConnectionToken
MandatoryServerConnectionToken
getWordDefinitionFor
FailedExtension
DocumentSemanticTokensAdapter
DocumentRangeSemanticTokensAdapter
startExtensionHostProcess
create
create
IResourceCreator
InsertSnippetResult
RangeHighlightDecorations
ScrollPosition
ITerminalEnvironmentVariableCollections
ConfigurationEditingError
IExtHostNamedCustomer
IExtHostCustomerCtor
DeltaExtensionsResult
ExtHostConnection
ExtensionHostStartupClassification
ExtensionHostStartupEvent
MessagePortLike
IResolveAuthorityOKResult
JSONStringifyReplacer
IExtensionActivationResult
NativeResolvedKeybinding
IScanCodeMapping
create
RemoteAgentConnection
IValidGrammarDefinitionDTO
ICreateData
IRawModelData
create
IEmbeddedLanguagesMap
IColorTheme
ITokenColorizationRule
ITokenColorizationSetting
assertCleanState
The text was updated successfully, but these errors were encountered: