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

Remove unused exports & dead code (using Knip) #56817

Merged
merged 30 commits into from
Jun 27, 2024

Conversation

webpro
Copy link
Contributor

@webpro webpro commented Dec 17, 2023

Fixes #56818

When running Knip with a bit of config (see knip.jsonc) I get these results:

$ npx knip
Unused files (1)
scripts/failed-tests.d.cts
Unused devDependencies (1)
@types/microsoft__typescript-etw  package.json
Unresolved imports (1)
./cancellationToken  src/tsserver/nodeServer.ts:360:33
Unused exports (13)
cleanTestDirs                 function  scripts/build/tests.mjs:177:23                  
writeTestConfigFile           function  scripts/build/tests.mjs:195:17                  
coverageDir                   unknown   scripts/build/tests.mjs:23:14                   
ROOT_DIR                      unknown   scripts/eslint/tests/support/RuleTester.cjs:4:16
FILENAME                      unknown   scripts/eslint/tests/support/RuleTester.cjs:5:16
enableDeprecationWarnings     unknown   src/deprecatedCompat/deprecate.ts:10:12         
setEnableDeprecationWarnings  function  src/deprecatedCompat/deprecate.ts:12:17         
createDeprecation             function  src/deprecatedCompat/deprecate.ts:48:17         
sanitizeLog                   function  src/harness/tsserverLogger.ts:111:17            
sanitizeLibFileText           function  src/harness/tsserverLogger.ts:141:17            
createLoggerWritingToConsole  function  src/harness/tsserverLogger.ts:96:17             
serializeMultiMap             function  src/harness/watchUtils.ts:157:17                
server                        unknown   src/typingsInstaller/_namespaces/ts.ts:7:9
Unused exports in namespaces (1)
server  unknown  src/typescript/_namespaces/ts.ts:8:9
Unused exported types (3)
Logger           interface  src/harness/tsserverLogger.ts:30:18
TestFileWatcher  interface  src/harness/watchUtils.ts:15:18    
TestFsWatcher    interface  src/harness/watchUtils.ts:20:18
Duplicate exports (2)
local, default                            Herebyfile.mjs       
getJSDocTagCompletionDetails, getJSDo...  src/services/jsDoc.ts

There are a few false positives, but I think the results are still quite useful.

Then I ran npx knip --fix to remove the export keywords for unused exports, and then I went into the file to check it and remove the remaining dead code. Running the tests does not give issues.

Let me know if I should remove Knip + config itself again, I totally understand you might not be eager to introduce new dependencies. Alternatively, I'm happy to extend the work until it reports no issues and then you can keep using this (in CI) it to prevent future regressions.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Dec 17, 2023
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@jakebailey
Copy link
Member

FWIW I had this exact change a couple of days ago, but decided not to send it because the benefit seemed small (as opposed to on DefinitelyTyped-tools where it found a lot of dead code and deps, and it's now part of CI).

What would be more interesting IMO would be for knip to process @internal and see how much dead exported code we have that isn't actually considered part of our public API. My impression is that our goofy API setup means that knip is not catching these.

@webpro
Copy link
Contributor Author

webpro commented Dec 19, 2023

We can fine-tune config however you like it. Knip does catch those @internal exports too if you want (it ignores @internal tags, except in --production mode).

My impression is that our goofy API setup means that knip is not catching these.

It's kind of the opposite: linting this codebase made me consider adding a --ignore-internal flag so we'll have even more angles to look at the repo.

The current config has src/*/_namespaces/*.ts in the entry files and Knip does not report unused exports from entry files. Reducing the entry files to the public API will likely reveal more unused exports indeed (I don't know what entails "public API").

Edit: --ignore-internal could then be combined with --include-entry-exports

@jakebailey
Copy link
Member

The only entrypoints should be those passed to entrypointBuildTask in the Herebyfile.

@webpro
Copy link
Contributor Author

webpro commented Dec 19, 2023

Oh well, then brace yourself... :)

@webpro
Copy link
Contributor Author

webpro commented Dec 28, 2023

The only entrypoints should be those passed to entrypointBuildTask in the Herebyfile.

Following that, using this config:

{
    "$schema": "https://unpkg.com/knip@3/schema.json",
    "entry": [
        "Herebyfile.mjs",
        // Knip does not understand Herebyfile.mjs (a new Knip plugin could probably handle it), so we add the entry files manually:
        "src/cancellationToken/cancellationToken.ts",
        "src/testRunner/_namespaces/Harness.ts",
        "src/tsc/tsc.ts",
        "src/tsserver/server.ts",
        "src/typescript/typescript.ts",
        "src/typingsInstaller/nodeTypingsInstaller.ts",
        "src/watchGuard/watchGuard.ts",

        // src/testRunner/tests.ts does not export anything, so we add all test files separately instead:
        "src/testRunner/unittests/**/*.ts",

        // The rest of the entry files, mostly to track used dependencies:
        ".eslintplugin.js",
        ".gulp.js",
        "scripts/eslint/{rules,tests}/*.cjs",
        "scripts/*.{cjs,mjs}"
    ],
    "ignore": [
        "src/lib/**",
        "tests/**"
    ],
    "ignoreDependencies": ["c8", "eslint-formatter-autolinkable-stylish", "mocha-fivemat-progress-reporter"],
    "ignoreExportsUsedInFile": {
        "enum": true,
        "interface": true,
        "type": true
    }
}

(output deleted, see next comment)

@webpro
Copy link
Contributor Author

webpro commented Dec 31, 2023

Did some more work on this, we're now at Knip v4.0.0-canary.5. The TS repo is great, because contains plenty of (challenging) grounds for Knip to cover. I expect the current usage/output to be fairly stable for v4.

The original output for this PR is improved with a default run:

Results for `knip`
❯ knip
Unused files (1)
scripts/failed-tests.d.cts
Unused devDependencies (1)
@types/microsoft__typescript-etw  package.json
Unresolved imports (1)
./cancellationToken  src/tsserver/nodeServer.ts:360:33
Unused exports (13)
cleanTestDirs                 function  scripts/build/tests.mjs:177:23                  
writeTestConfigFile           function  scripts/build/tests.mjs:195:17                  
coverageDir                   unknown   scripts/build/tests.mjs:23:14                   
ROOT_DIR                      unknown   scripts/eslint/tests/support/RuleTester.cjs:4:16
FILENAME                      unknown   scripts/eslint/tests/support/RuleTester.cjs:5:16
enableDeprecationWarnings     unknown   src/deprecatedCompat/deprecate.ts:10:12         
setEnableDeprecationWarnings  function  src/deprecatedCompat/deprecate.ts:12:17         
createDeprecation             function  src/deprecatedCompat/deprecate.ts:48:17         
sanitizeLog                   function  src/harness/tsserverLogger.ts:111:17            
sanitizeLibFileText           function  src/harness/tsserverLogger.ts:141:17            
createLoggerWritingToConsole  function  src/harness/tsserverLogger.ts:96:17             
serializeMultiMap             function  src/harness/watchUtils.ts:157:17                
server                        unknown   src/typingsInstaller/_namespaces/ts.ts:7:9
Unused exports in namespaces (26)
extractMessage              function  src/harness/client.ts:98:17                      
readProject                 function  src/harness/compilerImpl.ts:19:17                
TestCancellationToken       class     src/harness/fourslashImpl.ts:147:14              
verifyOperationIsCancelled  function  src/harness/fourslashImpl.ts:177:17              
ignoreInterpolations        function  src/harness/fourslashImpl.ts:190:17              
runFourSlashTestContent     function  src/harness/fourslashImpl.ts:4551:17             
VerifyNegatable             class     src/harness/fourslashInterfaceImpl.ts:126:14     
convertDiagnostics          function  src/harness/harnessUtils.ts:152:17               
filterStack                 function  src/harness/harnessUtils.ts:337:17               
readTestFile                function  src/harness/harnessUtils.ts:35:17                
evalFile                    function  src/harness/harnessUtils.ts:8:17                 
theory                      function  src/harness/util.ts:104:17                       
getByteOrderMarkLength      function  src/harness/util.ts:84:17                        
Stats                       class     src/harness/vfsUtil.ts:1272:14                   
IOErrorMessages             unknown   src/harness/vfsUtil.ts:1338:14                   
Directory                   class     src/harness/vfsUtil.ts:1371:14                   
SameFileContentFile         class     src/harness/vfsUtil.ts:1392:14                   
SameFileWithModifiedTime    class     src/harness/vfsUtil.ts:1398:14                   
Link                        class     src/harness/vfsUtil.ts:1405:14                   
Rmdir                       class     src/harness/vfsUtil.ts:1413:14                   
Unlink                      class     src/harness/vfsUtil.ts:1418:14                   
Mount                       class     src/harness/vfsUtil.ts:1433:14                   
projectsFolder              unknown   src/harness/vfsUtil.ts:15:14                     
iteratePatch                function  src/harness/vfsUtil.ts:1617:17                   
isJavaScriptSourceMap       function  src/harness/vpathUtil.ts:122:17                  
typingsInstaller            unknown   src/typingsInstaller/_namespaces/ts.server.ts:6:9
Unused exported types (2)
TestFileWatcher  interface  src/harness/watchUtils.ts:15:18
TestFsWatcher    interface  src/harness/watchUtils.ts:20:18
Unused exported types in namespaces (5)
ReferenceGroup                       interface  src/harness/fourslashInterfaceImpl.ts:1724:18
VerifyInlayHintsOptions              interface  src/harness/fourslashInterfaceImpl.ts:1823:18
VerifyCompletionListContainsOptions  interface  src/harness/fourslashInterfaceImpl.ts:1833:18
VerifyRefactorOptions                interface  src/harness/fourslashInterfaceImpl.ts:1875:18
RenameLocationsOptions               type       src/harness/fourslashInterfaceImpl.ts:1915:13
Duplicate exports (2)
local, default                            Herebyfile.mjs       
getJSDocTagCompletionDetails, getJSDo...  src/services/jsDoc.ts

What would be more interesting IMO would be for knip to process @internal and see how much dead exported code we have that isn't actually considered part of our public API. My impression is that our goofy API setup means that knip is not catching these.

It took me a few more iterations, but in the process Knip handles re-exports better and there's a --trace flag (for a ton of "file tree walking" logs). There's an --experimental-tags argument, but I'm not 100% sold on it yet. Feels pretty useful though, since Knip also motivates people to use @public and @internal flags, so such exports can be focused on separately (or excluded).

Results for `knip --include-entry-exports --experimental-tags=+internal `
❯ knip --include-entry-exports --experimental-tags=+internal
Unused files (1)
scripts/failed-tests.d.cts
Unused devDependencies (1)
@types/microsoft__typescript-etw  package.json
Unresolved imports (1)
./cancellationToken  src/tsserver/nodeServer.ts:360:33
Unused exports in namespaces (165)
signatureHasLiteralTypes                                      function  src/compiler/checker.ts:50763:17                   
compileOnSaveCommandLineOption                                unknown   src/compiler/commandLineParser.ts:126:14           
defaultInitCompilerOptions                                    unknown   src/compiler/commandLineParser.ts:1694:14          
defaultIncludeSpec                                            unknown   src/compiler/commandLineParser.ts:2851:14          
moduleOptionDeclaration                                       unknown   src/compiler/commandLineParser.ts:543:14           
toLowerCase                                                   function  src/compiler/core.ts:1923:17                       
memoizeWeak                                                   function  src/compiler/core.ts:2013:17                       
compose                                                       function  src/compiler/core.ts:2056:17                       
emptySet                                                      unknown   src/compiler/core.ts:20:14                         
findMap                                                       function  src/compiler/core.ts:226:17                        
unorderedRemoveItemAt                                         function  src/compiler/core.ts:2505:17                       
spreadArrayHelper                                             unknown   src/compiler/factory/emitHelpers.ts:1007:14        
propKeyHelper                                                 unknown   src/compiler/factory/emitHelpers.ts:1024:14        
setFunctionNameHelper                                         unknown   src/compiler/factory/emitHelpers.ts:1036:14        
valuesHelper                                                  unknown   src/compiler/factory/emitHelpers.ts:1050:14        
generatorHelper                                               unknown   src/compiler/factory/emitHelpers.ts:1132:14        
createBindingHelper                                           unknown   src/compiler/factory/emitHelpers.ts:1170:14        
setModuleDefaultHelper                                        unknown   src/compiler/factory/emitHelpers.ts:1190:14        
importStarHelper                                              unknown   src/compiler/factory/emitHelpers.ts:1205:14        
importDefaultHelper                                           unknown   src/compiler/factory/emitHelpers.ts:1223:14        
exportStarHelper                                              unknown   src/compiler/factory/emitHelpers.ts:1234:14        
classPrivateFieldGetHelper                                    unknown   src/compiler/factory/emitHelpers.ts:1296:14        
classPrivateFieldSetHelper                                    unknown   src/compiler/factory/emitHelpers.ts:1361:14        
classPrivateFieldInHelper                                     unknown   src/compiler/factory/emitHelpers.ts:1388:14        
addDisposableResourceHelper                                   unknown   src/compiler/factory/emitHelpers.ts:1402:14        
disposeResourcesHelper                                        unknown   src/compiler/factory/emitHelpers.ts:1432:14        
helperString                                                  function  src/compiler/factory/emitHelpers.ts:714:17         
decorateHelper                                                unknown   src/compiler/factory/emitHelpers.ts:729:14         
metadataHelper                                                unknown   src/compiler/factory/emitHelpers.ts:744:14         
paramHelper                                                   unknown   src/compiler/factory/emitHelpers.ts:756:14         
esDecorateHelper                                              unknown   src/compiler/factory/emitHelpers.ts:769:14         
runInitializersHelper                                         unknown   src/compiler/factory/emitHelpers.ts:805:14         
assignHelper                                                  unknown   src/compiler/factory/emitHelpers.ts:823:14         
awaitHelper                                                   unknown   src/compiler/factory/emitHelpers.ts:843:14         
asyncGeneratorHelper                                          unknown   src/compiler/factory/emitHelpers.ts:852:14         
asyncDelegator                                                unknown   src/compiler/factory/emitHelpers.ts:873:14         
asyncValues                                                   unknown   src/compiler/factory/emitHelpers.ts:887:14         
restHelper                                                    unknown   src/compiler/factory/emitHelpers.ts:904:14         
awaiterHelper                                                 unknown   src/compiler/factory/emitHelpers.ts:925:14         
extendsHelper                                                 unknown   src/compiler/factory/emitHelpers.ts:945:14         
templateObjectHelper                                          unknown   src/compiler/factory/emitHelpers.ts:970:14         
readHelper                                                    unknown   src/compiler/factory/emitHelpers.ts:983:14         
getIdentifierAutoGenerate                                     function  src/compiler/factory/emitNode.ts:368:17            
addNodeFactoryPatcher                                         function  src/compiler/factory/nodeFactory.ts:502:17         
getTransformFlagsSubtreeExclusions                            function  src/compiler/factory/nodeFactory.ts:7360:17        
canHaveIllegalType                                            function  src/compiler/factory/utilities.ts:1118:17          
isLiteralTypeLikeExpression                                   function  src/compiler/factory/utilities.ts:1185:17          
isNonExportDefaultModifier                                    function  src/compiler/factory/utilities.ts:1523:17          
insertLeadingStatement                                        function  src/compiler/factory/utilities.ts:338:17           
skipAssertions                                                function  src/compiler/factory/utilities.ts:684:17           
getOrCreateExternalHelpersModuleNameIfNeeded                  function  src/compiler/factory/utilities.ts:766:17           
bundlerModuleNameResolver                                     function  src/compiler/moduleNameResolver.ts:1767:17         
getPackageJsonInfo                                            function  src/compiler/moduleNameResolver.ts:2398:17         
createCacheWithRedirects                                      function  src/compiler/moduleNameResolver.ts:967:17          
parseBaseNodeFactory                                          unknown   src/compiler/parser.ts:426:14                      
comparePathsCaseInsensitive                                   function  src/compiler/path.ts:814:17                        
getPathComponentsRelativeTo                                   function  src/compiler/path.ts:891:17                        
typeReferenceResolutionNameAndModeGetter                      unknown   src/compiler/program.ts:1004:14                    
getImpliedNodeFormatForFileWorker                             function  src/compiler/program.ts:1322:17                    
plainJSErrors                                                 unknown   src/compiler/program.ts:1350:14                    
getRootPathSplitLength                                        function  src/compiler/resolutionCache.ts:449:17             
isOctalDigit                                                  function  src/compiler/scanner.ts:588:17                     
isShebangTrivia                                               function  src/compiler/scanner.ts:774:17                     
scanShebangTrivia                                             function  src/compiler/scanner.ts:781:17                     
isRawSourceMap                                                function  src/compiler/sourcemap.ts:409:17                   
setSys                                                        function  src/compiler/sys.ts:2030:17                        
sysLog                                                        function  src/compiler/sys.ts:545:17                         
createClassThisAssignmentBlock                                function  src/compiler/transformers/classThis.ts:34:17       
createClassNamedEvaluationHelperBlock                         function  src/compiler/transformers/namedEvaluation.ts:103:17
getAssignedNameOfIdentifier                                   function  src/compiler/transformers/namedEvaluation.ts:57:17 
IdentifierNameMultiMap                                        class     src/compiler/transformers/utilities.ts:411:14      
walkUpLexicalEnvironments                                     function  src/compiler/transformers/utilities.ts:783:17      
isSimpleParameter                                             function  src/compiler/transformers/utilities.ts:838:17      
getCurrentTime                                                function  src/compiler/tsbuildPublic.ts:215:17               
isCatchClauseVariableDeclaration                              function  src/compiler/utilities.ts:10350:17                 
getParameterTypeNode                                          function  src/compiler/utilities.ts:10476:17                 
insertStatementAfterStandardPrologue                          function  src/compiler/utilities.ts:1070:17                  
isEffectiveModuleDeclaration                                  function  src/compiler/utilities.ts:1786:17                  
fullTripleSlashReferencePathRegEx                             unknown   src/compiler/utilities.ts:2425:14                  
fullTripleSlashAMDReferencePathRegEx                          unknown   src/compiler/utilities.ts:2429:14                  
isChildOfNodeWithKind                                         function  src/compiler/utilities.ts:2531:17                  
isThisTypePredicate                                           function  src/compiler/utilities.ts:2742:17                  
isSuperOrSuperProperty                                        function  src/compiler/utilities.ts:3058:17                  
nodeIsDecorated                                               function  src/compiler/utilities.ts:3189:17                  
isSourceFileNotJS                                             function  src/compiler/utilities.ts:3460:17                  
isLiteralLikeAccess                                           function  src/compiler/utilities.ts:3781:17                  
isLiteralLikeElementAccess                                    function  src/compiler/utilities.ts:3790:17                  
getSingleInitializerOfVariableStatementOrPropertyDeclaration  function  src/compiler/utilities.ts:4135:17                  
hasTypeArguments                                              function  src/compiler/utilities.ts:4463:17                  
isAliasSymbolDeclaration                                      function  src/compiler/utilities.ts:4794:17                  
isFutureReservedKeyword                                       function  src/compiler/utilities.ts:4957:17                  
isStringAKeyword                                              function  src/compiler/utilities.ts:4968:17                  
getPropertyNameForUniqueESSymbol                              function  src/compiler/utilities.ts:5125:17                  
isESSymbolIdentifier                                          function  src/compiler/utilities.ts:5149:17                  
isProtoSetter                                                 function  src/compiler/utilities.ts:5161:17                  
isAnonymousFunctionDefinition                                 function  src/compiler/utilities.ts:5178:17                  
getOriginalSourceFile                                         function  src/compiler/utilities.ts:5328:17                  
getOperator                                                   function  src/compiler/utilities.ts:5393:17                  
getIndentSize                                                 function  src/compiler/utilities.ts:5994:17                  
getSourceFilePathInNewDirWorker                               function  src/compiler/utilities.ts:6392:17                  
getLineOfLocalPositionFromLineMap                             function  src/compiler/utilities.ts:6452:17                  
emitNewLineBeforeLeadingComments                              function  src/compiler/utilities.ts:6636:17                  
optionsHaveModuleResolutionChanges                            function  src/compiler/utilities.ts:663:17                   
emitNewLineBeforeLeadingCommentsOfPosition                    function  src/compiler/utilities.ts:6641:17                  
emitComments                                                  function  src/compiler/utilities.ts:6663:17                  
getSelectedSyntacticModifierFlags                             function  src/compiler/utilities.ts:6932:17                  
getSyntacticModifierFlagsNoCache                              function  src/compiler/utilities.ts:7029:17                  
isLeftHandSideOfAssignment                                    function  src/compiler/utilities.ts:7168:17                  
isCollapsedRange                                              function  src/compiler/utilities.ts:7588:17                  
rangeStartIsOnSameLineAsRangeEnd                              function  src/compiler/utilities.ts:7624:17                  
getLinesBetweenRangeEndPositions                              function  src/compiler/utilities.ts:7640:17                  
getStartPositionOfRange                                       function  src/compiler/utilities.ts:7655:17                  
forSomeAncestorDirectory                                      function  src/compiler/utilities.ts:7962:17                  
compareDiagnosticsSkipRelatedInformation                      function  src/compiler/utilities.ts:8477:17                  
getEmitModuleDetectionKind                                    unknown   src/compiler/utilities.ts:8835:14                  
commonPackageFolders                                          unknown   src/compiler/utilities.ts:9140:14                  
nodePosToString                                               function  src/compiler/utilities.ts:927:17                   
supportedTSExtensions                                         unknown   src/compiler/utilities.ts:9498:14                  
supportedJSExtensions                                         unknown   src/compiler/utilities.ts:9505:14                  
usesExtensionsOnImports                                       function  src/compiler/utilities.ts:9577:17                  
tryRemoveExtension                                            function  src/compiler/utilities.ts:9697:17                  
getJSDocTagsNoCache                                           function  src/compiler/utilitiesPublic.ts:1215:17            
isNode                                                        function  src/compiler/utilitiesPublic.ts:1420:17            
isNotEmittedOrPartiallyEmittedNode                            function  src/compiler/utilitiesPublic.ts:2082:17            
isScopeMarker                                                 function  src/compiler/utilitiesPublic.ts:2107:17            
isNamespaceBody                                               function  src/compiler/utilitiesPublic.ts:2157:17            
isJSDocNamespaceBody                                          function  src/compiler/utilitiesPublic.ts:2164:17            
supportedLocaleDirectories                                    unknown   src/compiler/utilitiesPublic.ts:623:14             
screenStartingMessageCodes                                    unknown   src/compiler/watch.ts:159:14                       
buildOverload                                                 function  src/deprecatedCompat/deprecations.ts:143:17        
createOverload                                                function  src/deprecatedCompat/deprecations.ts:83:17         
extractMessage                                                function  src/harness/client.ts:98:17                        
prefixedNodeCoreModuleList                                    unknown   src/jsTyping/jsTyping.ts:117:14                    
nodeCoreModules                                               unknown   src/jsTyping/jsTyping.ts:123:14                    
LineNode                                                      class     src/server/scriptVersionCache.ts:588:14            
LineLeaf                                                      class     src/server/scriptVersionCache.ts:840:14            
removeSorted                                                  function  src/server/utilities.ts:98:17                      
getArgumentTypesAndTypeParameters                             function  src/services/codefixes/helpers.ts:616:17           
createJsonPropertyAssignment                                  function  src/services/codefixes/helpers.ts:880:17           
findJsonProperty                                              function  src/services/codefixes/helpers.ts:885:17           
importSymbols                                                 function  src/services/codefixes/helpers.ts:928:17           
moduleSpecifierResolutionCacheAttemptLimit                    unknown   src/services/completions.ts:396:14                 
nodeEntry                                                     function  src/services/findAllReferences.ts:326:17           
isContextWithStartAndEndNode                                  function  src/services/findAllReferences.ts:335:17           
getTextSpanOfEntry                                            function  src/services/findAllReferences.ts:881:17           
findReferenceInPosition                                       function  src/services/goToDefinition.ts:673:17              
deleteUnusedImports                                           function  src/services/refactors/moveToFile.ts:616:17        
deleteNode                                                    function  src/services/textChanges.ts:1837:17                
hasChildOfKind                                                function  src/services/utilities.ts:1141:17                  
removeOptionality                                             function  src/services/utilities.ts:2000:17                  
isTypeKeywordToken                                            function  src/services/utilities.ts:2385:17                  
symbolPart                                                    function  src/services/utilities.ts:2862:17                  
linkTextPart                                                  function  src/services/utilities.ts:2948:17                  
linkNamePart                                                  function  src/services/utilities.ts:2953:17                  
linkPart                                                      function  src/services/utilities.ts:2965:17                  
nodeToDisplayParts                                            function  src/services/utilities.ts:3079:17                  
suppressTrailingTrivia                                        function  src/services/utilities.ts:3241:17                  
syntaxRequiresTrailingSemicolonOrASI                          function  src/services/utilities.ts:3479:17                  
syntaxMayBeASICandidate                                       unknown   src/services/utilities.ts:3498:14                  
tryIOAndConsumeErrors                                         function  src/services/utilities.ts:3639:17                  
getPackageJsonsVisibleToFile                                  function  src/services/utilities.ts:3672:17                  
isDiagnosticWithLocation                                      function  src/services/utilities.ts:3911:17                  
isGlobalDeclaration                                           function  src/services/utilities.ts:4097:17                  
isNonGlobalDeclaration                                        function  src/services/utilities.ts:4102:17                  
climbPastPropertyOrElementAccess                              function  src/services/utilities.ts:641:17
Unused exported types in namespaces (12)
AnyConstructor                     type       src/compiler/core.ts:2100:13    
Collection                         interface  src/compiler/corePublic.ts:42:18
HasIllegalExpressionInitializer    type       src/compiler/types.ts:1311:13   
UniqueTypeOperatorNode             interface  src/compiler/types.ts:2307:18   
ObjectAssignmentElement            type       src/compiler/types.ts:2659:13   
AssignmentElementTarget            type       src/compiler/types.ts:2690:13   
SyntheticSymbolKind                enum       src/compiler/types.ts:5472:19   
ResolvedProjectReferenceCallbacks  interface  src/compiler/types.ts:7877:18   
UniqueNameHandler                  type       src/compiler/types.ts:8100:13   
RenameFullResponse                 interface  src/server/protocol.ts:1313:18  
AnyEvent                           type       src/server/protocol.ts:3068:13  
OutliningSpansResponseFull         interface  src/server/protocol.ts:426:18
Unused exported enum members (51)
All                            BuilderFileEmit           src/compiler/builder.ts:193:5            
Off                            LogLevel                  src/compiler/debug.ts:99:5               
None                           NodeFactoryFlags          src/compiler/factory/nodeFactory.ts:488:5
c                              CharacterCodes            src/compiler/types.ts:7553:5             
d                              CharacterCodes            src/compiler/types.ts:7554:5             
g                              CharacterCodes            src/compiler/types.ts:7557:5             
h                              CharacterCodes            src/compiler/types.ts:7558:5             
j                              CharacterCodes            src/compiler/types.ts:7560:5             
k                              CharacterCodes            src/compiler/types.ts:7561:5             
l                              CharacterCodes            src/compiler/types.ts:7562:5             
p                              CharacterCodes            src/compiler/types.ts:7566:5             
q                              CharacterCodes            src/compiler/types.ts:7567:5             
s                              CharacterCodes            src/compiler/types.ts:7569:5             
w                              CharacterCodes            src/compiler/types.ts:7573:5             
y                              CharacterCodes            src/compiler/types.ts:7575:5             
C                              CharacterCodes            src/compiler/types.ts:7580:5             
D                              CharacterCodes            src/compiler/types.ts:7581:5             
G                              CharacterCodes            src/compiler/types.ts:7584:5             
H                              CharacterCodes            src/compiler/types.ts:7585:5             
J                              CharacterCodes            src/compiler/types.ts:7587:5             
K                              CharacterCodes            src/compiler/types.ts:7588:5             
L                              CharacterCodes            src/compiler/types.ts:7589:5             
P                              CharacterCodes            src/compiler/types.ts:7593:5             
Q                              CharacterCodes            src/compiler/types.ts:7594:5             
R                              CharacterCodes            src/compiler/types.ts:7595:5             
S                              CharacterCodes            src/compiler/types.ts:7596:5             
U                              CharacterCodes            src/compiler/types.ts:7598:5             
V                              CharacterCodes            src/compiler/types.ts:7599:5             
W                              CharacterCodes            src/compiler/types.ts:7600:5             
Y                              CharacterCodes            src/compiler/types.ts:7602:5             
backspace                      CharacterCodes            src/compiler/types.ts:7636:5             
AssertTypeScript               TransformFlags            src/compiler/types.ts:7926:5             
AssertJsx                      TransformFlags            src/compiler/types.ts:7927:5             
AssertESNext                   TransformFlags            src/compiler/types.ts:7928:5             
AssertES2022                   TransformFlags            src/compiler/types.ts:7929:5             
AssertES2021                   TransformFlags            src/compiler/types.ts:7930:5             
AssertES2020                   TransformFlags            src/compiler/types.ts:7931:5             
AssertES2019                   TransformFlags            src/compiler/types.ts:7932:5             
AssertES2018                   TransformFlags            src/compiler/types.ts:7933:5             
AssertES2017                   TransformFlags            src/compiler/types.ts:7934:5             
AssertES2016                   TransformFlags            src/compiler/types.ts:7935:5             
AssertES2015                   TransformFlags            src/compiler/types.ts:7936:5             
AssertGenerator                TransformFlags            src/compiler/types.ts:7937:5             
AssertDestructuringAssignment  TransformFlags            src/compiler/types.ts:7938:5             
Choice                         SnippetKind               src/compiler/types.ts:8027:5             
Variable                       SnippetKind               src/compiler/types.ts:8028:5             
None                           RelationComparisonResult  src/compiler/types.ts:919:5              
Default                        PragmaKindFlags           src/compiler/types.ts:9887:5             
None                           GetLiteralTextFlags       src/compiler/utilities.ts:1658:5         
Highest                        OperatorPrecedence        src/compiler/utilities.ts:5591:5         
None                           SemanticMeaning           src/services/utilities.ts:389:5
Duplicate exports (2)
local, default                            Herebyfile.mjs       
getJSDocTagCompletionDetails, getJSDo...  src/services/jsDoc.ts

The previous comment ()previous iteration) I deleted (to reduce noise), here's the output with less false positives that should have been there:

knip --include-entry-exports
❯ knip --include-entry-exports
Unused files (1)
scripts/failed-tests.d.cts
Unused devDependencies (1)
@types/microsoft__typescript-etw  package.json
Unresolved imports (1)
./cancellationToken  src/tsserver/nodeServer.ts:360:33
Unused exports (71)
default                                  unknown   .eslintplugin.js:8:17                                                
buildSrc                                 unknown   Herebyfile.mjs:142:14                                                
watchSrc                                 unknown   Herebyfile.mjs:149:14                                                
cleanSrc                                 unknown   Herebyfile.mjs:157:14                                                
watchTsc                                 unknown   Herebyfile.mjs:376:14                                                
tsc                                      unknown   Herebyfile.mjs:376:9                                                 
watchServices                            unknown   Herebyfile.mjs:389:19                                                
services                                 unknown   Herebyfile.mjs:389:9                                                 
dtsServices                              unknown   Herebyfile.mjs:391:14                                                
watchTsserver                            unknown   Herebyfile.mjs:412:19                                                
tsserver                                 unknown   Herebyfile.mjs:412:9                                                 
min                                      unknown   Herebyfile.mjs:414:14                                                
watchMin                                 unknown   Herebyfile.mjs:420:14                                                
dtsLssl                                  unknown   Herebyfile.mjs:464:14                                                
dts                                      unknown   Herebyfile.mjs:474:14                                                
watchTests                               unknown   Herebyfile.mjs:498:16                                                
tests                                    unknown   Herebyfile.mjs:498:9                                                 
runEslintRulesTests                      unknown   Herebyfile.mjs:500:14                                                
lint                                     unknown   Herebyfile.mjs:506:14                                                
format                                   unknown   Herebyfile.mjs:532:14                                                
checkFormat                              unknown   Herebyfile.mjs:538:14                                                
buildScripts                             unknown   Herebyfile.mjs:55:14                                                 
generateTypesMap                         unknown   Herebyfile.mjs:569:14                                                
otherOutputs                             unknown   Herebyfile.mjs:595:14                                                
watchOtherOutputs                        unknown   Herebyfile.mjs:601:14                                                
local                                    unknown   Herebyfile.mjs:608:14                                                
default                                  unknown   Herebyfile.mjs:613:8                                                 
watchLocal                               unknown   Herebyfile.mjs:615:14                                                
runTests                                 unknown   Herebyfile.mjs:624:14                                                
runTestsAndWatch                         unknown   Herebyfile.mjs:647:14                                                
generateLibs                             unknown   Herebyfile.mjs:74:14                                                 
runTestsParallel                         unknown   Herebyfile.mjs:764:14                                                
testBrowserIntegration                   unknown   Herebyfile.mjs:783:14                                                
diff                                     unknown   Herebyfile.mjs:790:14                                                
baselineAccept                           unknown   Herebyfile.mjs:824:14                                                
updateSublime                            unknown   Herebyfile.mjs:832:14                                                
produceLKG                               unknown   Herebyfile.mjs:843:14                                                
lkg                                      unknown   Herebyfile.mjs:874:14                                                
cleanBuilt                               unknown   Herebyfile.mjs:880:14                                                
clean                                    unknown   Herebyfile.mjs:886:14                                                
configureNightly                         unknown   Herebyfile.mjs:892:14                                                
configureInsiders                        unknown   Herebyfile.mjs:898:14                                                
configureExperimental                    unknown   Herebyfile.mjs:904:14                                                
help                                     unknown   Herebyfile.mjs:910:14                                                
generateDiagnostics                      unknown   Herebyfile.mjs:96:14                                                 
cleanTestDirs                            function  scripts/build/tests.mjs:177:23                                       
writeTestConfigFile                      function  scripts/build/tests.mjs:195:17                                       
coverageDir                              unknown   scripts/build/tests.mjs:23:14                                        
default                                  unknown   scripts/eslint/rules/jsdoc-format.cjs:4:17                           
ROOT_DIR                                 unknown   scripts/eslint/tests/support/RuleTester.cjs:4:16                     
FILENAME                                 unknown   scripts/eslint/tests/support/RuleTester.cjs:5:16                     
default                                  unknown   scripts/failed-tests.cjs:155:17                                      
runSequence                              function  scripts/run-sequence.mjs:9:17                                        
default                                  unknown   src/cancellationToken/cancellationToken.ts:69:8                      
enableDeprecationWarnings                unknown   src/deprecatedCompat/deprecate.ts:10:12                              
setEnableDeprecationWarnings             function  src/deprecatedCompat/deprecate.ts:12:17                              
createDeprecation                        function  src/deprecatedCompat/deprecate.ts:48:17                              
sanitizeLog                              function  src/harness/tsserverLogger.ts:111:17                                 
sanitizeLibFileText                      function  src/harness/tsserverLogger.ts:141:17                                 
createLoggerWritingToConsole             function  src/harness/tsserverLogger.ts:96:17                                  
serializeMultiMap                        function  src/harness/watchUtils.ts:157:17                                     
getServerHostForSampleProjectReferences  function  src/testRunner/unittests/helpers/sampleProjectReferences.ts:105:17   
testTscCompile                           function  src/testRunner/unittests/helpers/tsc.ts:129:17                       
isWatch                                  function  src/testRunner/unittests/helpers/tscWatch.ts:244:17                  
TestServerCancellationToken              class     src/testRunner/unittests/helpers/tsserver.ts:262:14                  
TestTypingsInstallerWorker               class     src/testRunner/unittests/helpers/typingsInstaller.ts:86:14           
getTripleSlashRef                        function  src/testRunner/unittests/helpers/vfs.ts:138:17                       
restContent                              function  src/testRunner/unittests/helpers/vfs.ts:93:17                        
isFile                                   function  src/testRunner/unittests/helpers/virtualFileSystemWithWatch.ts:118:17
default                                  unknown   src/typescript/typescript.ts:26:8                                    
server                                   unknown   src/typingsInstaller/_namespaces/ts.ts:7:9
Unused exports in namespaces (269)
performance                                                   unknown   src/compiler/_namespaces/ts.ts:77:9                
signatureHasLiteralTypes                                      function  src/compiler/checker.ts:50763:17                   
compileOnSaveCommandLineOption                                unknown   src/compiler/commandLineParser.ts:126:14           
defaultInitCompilerOptions                                    unknown   src/compiler/commandLineParser.ts:1694:14          
defaultIncludeSpec                                            unknown   src/compiler/commandLineParser.ts:2851:14          
convertTypeAcquisitionFromJson                                function  src/compiler/commandLineParser.ts:3418:17          
moduleOptionDeclaration                                       unknown   src/compiler/commandLineParser.ts:543:14           
toLowerCase                                                   function  src/compiler/core.ts:1923:17                       
memoizeWeak                                                   function  src/compiler/core.ts:2013:17                       
compose                                                       function  src/compiler/core.ts:2056:17                       
emptySet                                                      unknown   src/compiler/core.ts:20:14                         
findMap                                                       function  src/compiler/core.ts:226:17                        
unorderedRemoveItemAt                                         function  src/compiler/core.ts:2505:17                       
spreadArrayHelper                                             unknown   src/compiler/factory/emitHelpers.ts:1007:14        
propKeyHelper                                                 unknown   src/compiler/factory/emitHelpers.ts:1024:14        
setFunctionNameHelper                                         unknown   src/compiler/factory/emitHelpers.ts:1036:14        
valuesHelper                                                  unknown   src/compiler/factory/emitHelpers.ts:1050:14        
generatorHelper                                               unknown   src/compiler/factory/emitHelpers.ts:1132:14        
createBindingHelper                                           unknown   src/compiler/factory/emitHelpers.ts:1170:14        
setModuleDefaultHelper                                        unknown   src/compiler/factory/emitHelpers.ts:1190:14        
importStarHelper                                              unknown   src/compiler/factory/emitHelpers.ts:1205:14        
importDefaultHelper                                           unknown   src/compiler/factory/emitHelpers.ts:1223:14        
exportStarHelper                                              unknown   src/compiler/factory/emitHelpers.ts:1234:14        
classPrivateFieldGetHelper                                    unknown   src/compiler/factory/emitHelpers.ts:1296:14        
classPrivateFieldSetHelper                                    unknown   src/compiler/factory/emitHelpers.ts:1361:14        
classPrivateFieldInHelper                                     unknown   src/compiler/factory/emitHelpers.ts:1388:14        
addDisposableResourceHelper                                   unknown   src/compiler/factory/emitHelpers.ts:1402:14        
disposeResourcesHelper                                        unknown   src/compiler/factory/emitHelpers.ts:1432:14        
helperString                                                  function  src/compiler/factory/emitHelpers.ts:714:17         
decorateHelper                                                unknown   src/compiler/factory/emitHelpers.ts:729:14         
metadataHelper                                                unknown   src/compiler/factory/emitHelpers.ts:744:14         
paramHelper                                                   unknown   src/compiler/factory/emitHelpers.ts:756:14         
esDecorateHelper                                              unknown   src/compiler/factory/emitHelpers.ts:769:14         
runInitializersHelper                                         unknown   src/compiler/factory/emitHelpers.ts:805:14         
assignHelper                                                  unknown   src/compiler/factory/emitHelpers.ts:823:14         
awaitHelper                                                   unknown   src/compiler/factory/emitHelpers.ts:843:14         
asyncGeneratorHelper                                          unknown   src/compiler/factory/emitHelpers.ts:852:14         
asyncDelegator                                                unknown   src/compiler/factory/emitHelpers.ts:873:14         
asyncValues                                                   unknown   src/compiler/factory/emitHelpers.ts:887:14         
restHelper                                                    unknown   src/compiler/factory/emitHelpers.ts:904:14         
awaiterHelper                                                 unknown   src/compiler/factory/emitHelpers.ts:925:14         
extendsHelper                                                 unknown   src/compiler/factory/emitHelpers.ts:945:14         
templateObjectHelper                                          unknown   src/compiler/factory/emitHelpers.ts:970:14         
readHelper                                                    unknown   src/compiler/factory/emitHelpers.ts:983:14         
getTokenSourceMapRange                                        function  src/compiler/factory/emitNode.ts:147:17            
removeEmitHelper                                              function  src/compiler/factory/emitNode.ts:271:17            
getIdentifierAutoGenerate                                     function  src/compiler/factory/emitNode.ts:368:17            
addNodeFactoryPatcher                                         function  src/compiler/factory/nodeFactory.ts:502:17         
getTransformFlagsSubtreeExclusions                            function  src/compiler/factory/nodeFactory.ts:7360:17        
createInputFiles                                              function  src/compiler/factory/nodeFactory.ts:7625:17        
isJSDocLinkPlain                                              function  src/compiler/factory/nodeTests.ts:1059:17          
isJSDocNamepathType                                           function  src/compiler/factory/nodeTests.ts:1091:17          
isJSDocAuthorTag                                              function  src/compiler/factory/nodeTests.ts:1113:17          
isJSDocSeeTag                                                 function  src/compiler/factory/nodeTests.ts:1153:17          
isJSDocUnknownTag                                             function  src/compiler/factory/nodeTests.ts:1185:17          
isJSDocThrowsTag                                              function  src/compiler/factory/nodeTests.ts:1201:17          
isSyntheticExpression                                         function  src/compiler/factory/nodeTests.ts:692:17           
isDoStatement                                                 function  src/compiler/factory/nodeTests.ts:736:17           
isWhileStatement                                              function  src/compiler/factory/nodeTests.ts:740:17           
isContinueStatement                                           function  src/compiler/factory/nodeTests.ts:756:17           
isBreakStatement                                              function  src/compiler/factory/nodeTests.ts:760:17           
isDebuggerStatement                                           function  src/compiler/factory/nodeTests.ts:788:17           
isImportTypeAssertionContainer                                function  src/compiler/factory/nodeTests.ts:848:17           
isAssertEntry                                                 function  src/compiler/factory/nodeTests.ts:858:17           
isMissingDeclaration                                          function  src/compiler/factory/nodeTests.ts:902:17           
canHaveIllegalType                                            function  src/compiler/factory/utilities.ts:1118:17          
isLiteralTypeLikeExpression                                   function  src/compiler/factory/utilities.ts:1185:17          
isNonExportDefaultModifier                                    function  src/compiler/factory/utilities.ts:1523:17          
insertLeadingStatement                                        function  src/compiler/factory/utilities.ts:338:17           
skipAssertions                                                function  src/compiler/factory/utilities.ts:684:17           
getOrCreateExternalHelpersModuleNameIfNeeded                  function  src/compiler/factory/utilities.ts:766:17           
resolveModuleNameFromCache                                    function  src/compiler/moduleNameResolver.ts:1391:17         
bundlerModuleNameResolver                                     function  src/compiler/moduleNameResolver.ts:1767:17         
getPackageJsonInfo                                            function  src/compiler/moduleNameResolver.ts:2398:17         
classicNameResolver                                           function  src/compiler/moduleNameResolver.ts:3188:17         
createCacheWithRedirects                                      function  src/compiler/moduleNameResolver.ts:967:17          
parseBaseNodeFactory                                          unknown   src/compiler/parser.ts:426:14                      
comparePathsCaseInsensitive                                   function  src/compiler/path.ts:814:17                        
getPathComponentsRelativeTo                                   function  src/compiler/path.ts:891:17                        
typeReferenceResolutionNameAndModeGetter                      unknown   src/compiler/program.ts:1004:14                    
getImpliedNodeFormatForFileWorker                             function  src/compiler/program.ts:1322:17                    
plainJSErrors                                                 unknown   src/compiler/program.ts:1350:14                    
createCompilerHost                                            function  src/compiler/program.ts:391:17                     
getModeForFileReference                                       function  src/compiler/program.ts:849:17                     
getRootPathSplitLength                                        function  src/compiler/resolutionCache.ts:449:17             
isOctalDigit                                                  function  src/compiler/scanner.ts:588:17                     
isShebangTrivia                                               function  src/compiler/scanner.ts:774:17                     
scanShebangTrivia                                             function  src/compiler/scanner.ts:781:17                     
reduceEachLeadingCommentRange                                 function  src/compiler/scanner.ts:925:17                     
reduceEachTrailingCommentRange                                function  src/compiler/scanner.ts:929:17                     
isRawSourceMap                                                function  src/compiler/sourcemap.ts:409:17                   
setSys                                                        function  src/compiler/sys.ts:2030:17                        
sysLog                                                        function  src/compiler/sys.ts:545:17                         
createClassThisAssignmentBlock                                function  src/compiler/transformers/classThis.ts:34:17       
createClassNamedEvaluationHelperBlock                         function  src/compiler/transformers/namedEvaluation.ts:103:17
getAssignedNameOfIdentifier                                   function  src/compiler/transformers/namedEvaluation.ts:57:17 
IdentifierNameMultiMap                                        class     src/compiler/transformers/utilities.ts:411:14      
walkUpLexicalEnvironments                                     function  src/compiler/transformers/utilities.ts:783:17      
isSimpleParameter                                             function  src/compiler/transformers/utilities.ts:838:17      
getCurrentTime                                                function  src/compiler/tsbuildPublic.ts:215:17               
isCatchClauseVariableDeclaration                              function  src/compiler/utilities.ts:10350:17                 
getParameterTypeNode                                          function  src/compiler/utilities.ts:10476:17                 
insertStatementAfterStandardPrologue                          function  src/compiler/utilities.ts:1070:17                  
isEffectiveModuleDeclaration                                  function  src/compiler/utilities.ts:1786:17                  
fullTripleSlashReferencePathRegEx                             unknown   src/compiler/utilities.ts:2425:14                  
fullTripleSlashAMDReferencePathRegEx                          unknown   src/compiler/utilities.ts:2429:14                  
isChildOfNodeWithKind                                         function  src/compiler/utilities.ts:2531:17                  
isThisTypePredicate                                           function  src/compiler/utilities.ts:2742:17                  
isSuperOrSuperProperty                                        function  src/compiler/utilities.ts:3058:17                  
nodeIsDecorated                                               function  src/compiler/utilities.ts:3189:17                  
isSourceFileNotJS                                             function  src/compiler/utilities.ts:3460:17                  
isLiteralLikeAccess                                           function  src/compiler/utilities.ts:3781:17                  
isLiteralLikeElementAccess                                    function  src/compiler/utilities.ts:3790:17                  
getSingleInitializerOfVariableStatementOrPropertyDeclaration  function  src/compiler/utilities.ts:4135:17                  
hasTypeArguments                                              function  src/compiler/utilities.ts:4463:17                  
isAliasSymbolDeclaration                                      function  src/compiler/utilities.ts:4794:17                  
isFutureReservedKeyword                                       function  src/compiler/utilities.ts:4957:17                  
isStringAKeyword                                              function  src/compiler/utilities.ts:4968:17                  
getPropertyNameForUniqueESSymbol                              function  src/compiler/utilities.ts:5125:17                  
isESSymbolIdentifier                                          function  src/compiler/utilities.ts:5149:17                  
isProtoSetter                                                 function  src/compiler/utilities.ts:5161:17                  
isAnonymousFunctionDefinition                                 function  src/compiler/utilities.ts:5178:17                  
getOriginalSourceFile                                         function  src/compiler/utilities.ts:5328:17                  
getOperator                                                   function  src/compiler/utilities.ts:5393:17                  
getIndentSize                                                 function  src/compiler/utilities.ts:5994:17                  
getSourceFilePathInNewDirWorker                               function  src/compiler/utilities.ts:6392:17                  
getLineOfLocalPositionFromLineMap                             function  src/compiler/utilities.ts:6452:17                  
emitNewLineBeforeLeadingComments                              function  src/compiler/utilities.ts:6636:17                  
optionsHaveModuleResolutionChanges                            function  src/compiler/utilities.ts:663:17                   
emitNewLineBeforeLeadingCommentsOfPosition                    function  src/compiler/utilities.ts:6641:17                  
emitComments                                                  function  src/compiler/utilities.ts:6663:17                  
getSelectedSyntacticModifierFlags                             function  src/compiler/utilities.ts:6932:17                  
getSyntacticModifierFlagsNoCache                              function  src/compiler/utilities.ts:7029:17                  
isLeftHandSideOfAssignment                                    function  src/compiler/utilities.ts:7168:17                  
isCollapsedRange                                              function  src/compiler/utilities.ts:7588:17                  
rangeStartIsOnSameLineAsRangeEnd                              function  src/compiler/utilities.ts:7624:17                  
getLinesBetweenRangeEndPositions                              function  src/compiler/utilities.ts:7640:17                  
getStartPositionOfRange                                       function  src/compiler/utilities.ts:7655:17                  
forSomeAncestorDirectory                                      function  src/compiler/utilities.ts:7962:17                  
compareDiagnosticsSkipRelatedInformation                      function  src/compiler/utilities.ts:8477:17                  
getEmitModuleDetectionKind                                    unknown   src/compiler/utilities.ts:8835:14                  
commonPackageFolders                                          unknown   src/compiler/utilities.ts:9140:14                  
nodePosToString                                               function  src/compiler/utilities.ts:927:17                   
supportedTSExtensions                                         unknown   src/compiler/utilities.ts:9498:14                  
supportedJSExtensions                                         unknown   src/compiler/utilities.ts:9505:14                  
usesExtensionsOnImports                                       function  src/compiler/utilities.ts:9577:17                  
tryRemoveExtension                                            function  src/compiler/utilities.ts:9697:17                  
getJSDocPublicTag                                             function  src/compiler/utilitiesPublic.ts:1062:17            
getJSDocPrivateTag                                            function  src/compiler/utilitiesPublic.ts:1072:17            
getJSDocProtectedTag                                          function  src/compiler/utilitiesPublic.ts:1082:17            
getJSDocReadonlyTag                                           function  src/compiler/utilitiesPublic.ts:1092:17            
getJSDocReturnTag                                             function  src/compiler/utilitiesPublic.ts:1126:17            
getJSDocTemplateTag                                           function  src/compiler/utilitiesPublic.ts:1131:17            
getJSDocTagsNoCache                                           function  src/compiler/utilitiesPublic.ts:1215:17            
getAllJSDocTagsOfKind                                         function  src/compiler/utilitiesPublic.ts:1230:17            
isUnparsedTextLike                                            function  src/compiler/utilitiesPublic.ts:1391:17            
isNode                                                        function  src/compiler/utilitiesPublic.ts:1420:17            
isTypeOnlyExportDeclaration                                   function  src/compiler/utilitiesPublic.ts:1512:17            
isNotEmittedOrPartiallyEmittedNode                            function  src/compiler/utilitiesPublic.ts:2082:17            
isScopeMarker                                                 function  src/compiler/utilitiesPublic.ts:2107:17            
isNamespaceBody                                               function  src/compiler/utilitiesPublic.ts:2157:17            
isJSDocNamespaceBody                                          function  src/compiler/utilitiesPublic.ts:2164:17            
textSpanIsEmpty                                               function  src/compiler/utilitiesPublic.ts:331:17             
textSpanOverlapsWith                                          function  src/compiler/utilitiesPublic.ts:349:17             
textSpanOverlap                                               function  src/compiler/utilitiesPublic.ts:353:17             
textSpanIntersectsWithTextSpan                                function  src/compiler/utilitiesPublic.ts:358:17             
textSpanIntersection                                          function  src/compiler/utilitiesPublic.ts:376:17             
getTypeParameterOwner                                         function  src/compiler/utilitiesPublic.ts:539:17             
isEmptyBindingPattern                                         function  src/compiler/utilitiesPublic.ts:555:17             
isEmptyBindingElement                                         function  src/compiler/utilitiesPublic.ts:565:17             
supportedLocaleDirectories                                    unknown   src/compiler/utilitiesPublic.ts:623:14             
getNameOfJSDocTypedef                                         function  src/compiler/utilitiesPublic.ts:877:17             
screenStartingMessageCodes                                    unknown   src/compiler/watch.ts:159:14                       
createWatchCompilerHost                                       function  src/compiler/watchPublic.ts:366:17                 
buildOverload                                                 function  src/deprecatedCompat/deprecations.ts:143:17        
createOverload                                                function  src/deprecatedCompat/deprecations.ts:83:17         
SourceMapRecorder                                             unknown   src/harness/_namespaces/Harness.ts:9:9             
extractMessage                                                function  src/harness/client.ts:98:17                        
readProject                                                   function  src/harness/compilerImpl.ts:19:17                  
TestCancellationToken                                         class     src/harness/fourslashImpl.ts:147:14                
verifyOperationIsCancelled                                    function  src/harness/fourslashImpl.ts:177:17                
ignoreInterpolations                                          function  src/harness/fourslashImpl.ts:190:17                
runFourSlashTestContent                                       function  src/harness/fourslashImpl.ts:4551:17               
VerifyNegatable                                               class     src/harness/fourslashInterfaceImpl.ts:126:14       
isBuiltFile                                                   function  src/harness/harnessIO.ts:1536:17                   
getDefaultLibraryFile                                         function  src/harness/harnessIO.ts:1541:17                   
libFolder                                                     unknown   src/harness/harnessIO.ts:191:14                    
setHarnessIO                                                  function  src/harness/harnessIO.ts:44:17                     
harnessNewLine                                                unknown   src/harness/harnessIO.ts:50:14                     
convertDiagnostics                                            function  src/harness/harnessUtils.ts:152:17                 
filterStack                                                   function  src/harness/harnessUtils.ts:337:17                 
readTestFile                                                  function  src/harness/harnessUtils.ts:35:17                  
evalFile                                                      function  src/harness/harnessUtils.ts:8:17                   
theory                                                        function  src/harness/util.ts:104:17                         
getByteOrderMarkLength                                        function  src/harness/util.ts:84:17                          
Stats                                                         class     src/harness/vfsUtil.ts:1272:14                     
IOErrorMessages                                               unknown   src/harness/vfsUtil.ts:1338:14                     
Directory                                                     class     src/harness/vfsUtil.ts:1371:14                     
SameFileContentFile                                           class     src/harness/vfsUtil.ts:1392:14                     
SameFileWithModifiedTime                                      class     src/harness/vfsUtil.ts:1398:14                     
Link                                                          class     src/harness/vfsUtil.ts:1405:14                     
Rmdir                                                         class     src/harness/vfsUtil.ts:1413:14                     
Unlink                                                        class     src/harness/vfsUtil.ts:1418:14                     
Mount                                                         class     src/harness/vfsUtil.ts:1433:14                     
projectsFolder                                                unknown   src/harness/vfsUtil.ts:15:14                       
iteratePatch                                                  function  src/harness/vfsUtil.ts:1617:17                     
isJavaScriptSourceMap                                         function  src/harness/vpathUtil.ts:122:17                    
prefixedNodeCoreModuleList                                    unknown   src/jsTyping/jsTyping.ts:117:14                    
nodeCoreModules                                               unknown   src/jsTyping/jsTyping.ts:123:14                    
convertCompilerOptions                                        function  src/server/editorServices.ts:452:17                
convertWatchOptions                                           function  src/server/editorServices.ts:462:17                
convertTypeAcquisition                                        function  src/server/editorServices.ts:476:17                
tryConvertScriptKindName                                      function  src/server/editorServices.ts:486:17                
allRootFilesAreJsOrDts                                        function  src/server/project.ts:227:17                       
allFilesAreJsOrDts                                            function  src/server/project.ts:232:17                       
LineNode                                                      class     src/server/scriptVersionCache.ts:588:14            
LineLeaf                                                      class     src/server/scriptVersionCache.ts:840:14            
removeSorted                                                  function  src/server/utilities.ts:98:17                      
createSortedArray                                             function  src/server/utilitiesPublic.ts:139:17               
createNormalizedPathMap                                       function  src/server/utilitiesPublic.ts:91:17                
v2020                                                         unknown   src/services/_namespaces/ts.classifier.ts:4:9      
addOrRemoveBracesToArrowFunction                              unknown   src/services/_namespaces/ts.refactor.ts:12:9       
convertArrowFunctionOrFunctionExpression                      unknown   src/services/_namespaces/ts.refactor.ts:14:9       
convertParamsToDestructuredObject                             unknown   src/services/_namespaces/ts.refactor.ts:16:9       
convertStringOrTemplateLiteral                                unknown   src/services/_namespaces/ts.refactor.ts:18:9       
convertToOptionalChainExpression                              unknown   src/services/_namespaces/ts.refactor.ts:20:9       
extractSymbol                                                 unknown   src/services/_namespaces/ts.refactor.ts:22:9       
generateGetAccessorAndSetAccessor                             unknown   src/services/_namespaces/ts.refactor.ts:24:9       
inferFunctionReturnType                                       unknown   src/services/_namespaces/ts.refactor.ts:26:9       
classifier                                                    unknown   src/services/_namespaces/ts.ts:24:9                
NavigateTo                                                    unknown   src/services/_namespaces/ts.ts:38:9                
NavigationBar                                                 unknown   src/services/_namespaces/ts.ts:40:9                
getArgumentTypesAndTypeParameters                             function  src/services/codefixes/helpers.ts:616:17           
createJsonPropertyAssignment                                  function  src/services/codefixes/helpers.ts:880:17           
findJsonProperty                                              function  src/services/codefixes/helpers.ts:885:17           
importSymbols                                                 function  src/services/codefixes/helpers.ts:928:17           
moduleSpecifierResolutionCacheAttemptLimit                    unknown   src/services/completions.ts:396:14                 
nodeEntry                                                     function  src/services/findAllReferences.ts:326:17           
isContextWithStartAndEndNode                                  function  src/services/findAllReferences.ts:335:17           
getTextSpanOfEntry                                            function  src/services/findAllReferences.ts:881:17           
findReferenceInPosition                                       function  src/services/goToDefinition.ts:673:17              
deleteUnusedImports                                           function  src/services/refactors/moveToFile.ts:616:17        
servicesVersion                                               unknown   src/services/services.ts:332:14                    
deleteNode                                                    function  src/services/textChanges.ts:1837:17                
hasChildOfKind                                                function  src/services/utilities.ts:1141:17                  
removeOptionality                                             function  src/services/utilities.ts:2000:17                  
isTypeKeywordToken                                            function  src/services/utilities.ts:2385:17                  
symbolPart                                                    function  src/services/utilities.ts:2862:17                  
linkTextPart                                                  function  src/services/utilities.ts:2948:17                  
linkNamePart                                                  function  src/services/utilities.ts:2953:17                  
linkPart                                                      function  src/services/utilities.ts:2965:17                  
nodeToDisplayParts                                            function  src/services/utilities.ts:3079:17                  
suppressTrailingTrivia                                        function  src/services/utilities.ts:3241:17                  
syntaxRequiresTrailingSemicolonOrASI                          function  src/services/utilities.ts:3479:17                  
syntaxMayBeASICandidate                                       unknown   src/services/utilities.ts:3498:14                  
tryIOAndConsumeErrors                                         function  src/services/utilities.ts:3639:17                  
getPackageJsonsVisibleToFile                                  function  src/services/utilities.ts:3672:17                  
isDiagnosticWithLocation                                      function  src/services/utilities.ts:3911:17                  
isGlobalDeclaration                                           function  src/services/utilities.ts:4097:17                  
isNonGlobalDeclaration                                        function  src/services/utilities.ts:4102:17                  
climbPastPropertyOrElementAccess                              function  src/services/utilities.ts:641:17                   
Host                                                          unknown   src/testRunner/_namespaces/Harness.Parallel.ts:5:9 
Worker                                                        unknown   src/testRunner/_namespaces/Harness.Parallel.ts:7:9 
iterations                                                    unknown   src/testRunner/runner.ts:21:12                     
isWorker                                                      unknown   src/testRunner/runner.ts:245:12                    
server                                                        unknown   src/tsserver/_namespaces/ts.ts:8:9                 
server                                                        unknown   src/typescript/_namespaces/ts.ts:8:9               
typingsInstaller                                              unknown   src/typingsInstaller/_namespaces/ts.server.ts:6:9  
NodeTypingsInstaller                                          class     src/typingsInstaller/nodeTypingsInstaller.ts:100:14
Unused exported types (5)
TestFileWatcher         interface  src/harness/watchUtils.ts:15:18                                      
TestFsWatcher           interface  src/harness/watchUtils.ts:20:18                                      
PendingInstallCallback  type       src/testRunner/unittests/helpers/typingsInstaller.ts:80:13           
TestServerHostOptions   interface  src/testRunner/unittests/helpers/virtualFileSystemWithWatch.ts:309:18
PendingInstallCallback  type       src/testRunner/unittests/helpers/virtualFileSystemWithWatch.ts:318:13
Unused exported types in namespaces (63)
AnyConstructor                                 type       src/compiler/core.ts:2100:13                 
Collection                                     interface  src/compiler/corePublic.ts:42:18             
HasIllegalExpressionInitializer                type       src/compiler/types.ts:1311:13                
AssertKeyword                                  type       src/compiler/types.ts:1604:13                
ParameterPropertyModifier                      type       src/compiler/types.ts:1651:13                
ClassMemberModifier                            type       src/compiler/types.ts:1655:13                
TransientIdentifier                            interface  src/compiler/types.ts:1690:18                
FunctionLike                                   type       src/compiler/types.ts:2055:13                
UniqueTypeOperatorNode                         interface  src/compiler/types.ts:2307:18                
IncrementExpression                            type       src/compiler/types.ts:2387:13                
ObjectAssignmentElement                        type       src/compiler/types.ts:2659:13                
AssignmentElementTarget                        type       src/compiler/types.ts:2690:13                
SourceMapSpan                                  interface  src/compiler/types.ts:4870:18                
SyntheticSymbolKind                            enum       src/compiler/types.ts:5472:19                
ReadonlyUnderscoreEscapedMap                   type       src/compiler/types.ts:5987:13                
UnderscoreEscapedMap                           type       src/compiler/types.ts:5990:13                
ResolvedProjectReferenceCallbacks              interface  src/compiler/types.ts:7877:18                
UniqueNameHandler                              type       src/compiler/types.ts:8100:13                
ReferenceGroup                                 interface  src/harness/fourslashInterfaceImpl.ts:1724:18
VerifyInlayHintsOptions                        interface  src/harness/fourslashInterfaceImpl.ts:1823:18
VerifyCompletionListContainsOptions            interface  src/harness/fourslashInterfaceImpl.ts:1833:18
VerifyRefactorOptions                          interface  src/harness/fourslashInterfaceImpl.ts:1875:18
RenameLocationsOptions                         type       src/harness/fourslashInterfaceImpl.ts:1915:13
SourceMapEmitterCallback                       type       src/harness/harnessIO.ts:193:13              
DefinitionInfoAndBoundSpanReponse              type       src/server/protocol.ts:1100:13               
JsxClosingTagResponse                          interface  src/server/protocol.ts:1141:18               
LinkedEditingRangeResponse                     interface  src/server/protocol.ts:1154:18               
RenameFullResponse                             interface  src/server/protocol.ts:1313:18               
SelectionRangeResponse                         interface  src/server/protocol.ts:1683:18               
OpenExternalProjectResponse                    interface  src/server/protocol.ts:1783:18               
OpenExternalProjectsResponse                   interface  src/server/protocol.ts:1790:18               
CloseExternalProjectResponse                   interface  src/server/protocol.ts:1815:18               
SetCompilerOptionsForInferredProjectsResponse  interface  src/server/protocol.ts:1939:18               
ExitRequest                                    interface  src/server/protocol.ts:1946:18               
CompileOnSaveAffectedFileListResponse          interface  src/server/protocol.ts:2002:18               
CompileOnSaveEmitFileResponse                  interface  src/server/protocol.ts:2027:18               
ReloadProjectsRequest                          interface  src/server/protocol.ts:214:18                
JSDocLinkDisplayPart                           interface  src/server/protocol.ts:2317:18               
CompletionsResponse                            interface  src/server/protocol.ts:2473:18               
CompletionDetailsResponse                      interface  src/server/protocol.ts:2496:18               
AnyEvent                                       type       src/server/protocol.ts:3068:13               
ReloadResponse                                 interface  src/server/protocol.ts:3109:18               
SavetoRequest                                  interface  src/server/protocol.ts:3130:18               
StatusResponse                                 interface  src/server/protocol.ts:318:18                
DocCommandTemplateResponse                     interface  src/server/protocol.ts:332:18                
TypesInstallerInitializationFailedEvent        interface  src/server/protocol.ts:3330:18               
BeginInstallTypesEvent                         interface  src/server/protocol.ts:3392:18               
EndInstallTypesEvent                           interface  src/server/protocol.ts:3397:18               
TodoCommentsResponse                           interface  src/server/protocol.ts:357:18                
ClassificationType                             enum       src/server/protocol.ts:3774:19               
OutliningSpansResponseFull                     interface  src/server/protocol.ts:426:18                
IndentationResponse                            interface  src/server/protocol.ts:441:18                
OrganizeImportsResponse                        interface  src/server/protocol.ts:753:18                
GetEditsForFileRenameResponse                  interface  src/server/protocol.ts:768:18                
GetCombinedCodeFixResponse                     interface  src/server/protocol.ts:785:18                
ApplyCodeActionCommandResponse                 interface  src/server/protocol.ts:795:18                
GetCodeFixesResponse                           interface  src/server/protocol.ts:861:18                
GetSupportedCodeFixesResponse                  interface  src/server/protocol.ts:883:18                
DefinitionAndBoundSpanResponse                 interface  src/server/protocol.ts:981:18                
RequireResult                                  type       src/server/types.ts:18:13                    
CompressedData                                 interface  src/server/types.ts:9:18                     
OutputFileType                                 enum       src/services/types.ts:1518:19                
TaskSet                                        interface  src/testRunner/runner.ts:109:18
Unused exported enum members (75)
All                            BuilderFileEmit        src/compiler/builder.ts:193:5            
Off                            LogLevel               src/compiler/debug.ts:99:5               
None                           NodeFactoryFlags       src/compiler/factory/nodeFactory.ts:488:5
StringLiteralFlags             TokenFlags             src/compiler/types.ts:2798:5             
JSDocComment                   SyntaxKind             src/compiler/types.ts:419:5              
AddUndefined                   TypeFormatFlags        src/compiler/types.ts:5396:5             
InArrayType                    TypeFormatFlags        src/compiler/types.ts:5400:5             
InElementType                  TypeFormatFlags        src/compiler/types.ts:5401:5             
InFirstTypeArgument            TypeFormatFlags        src/compiler/types.ts:5402:5             
Global                         InternalSymbolName     src/compiler/types.ts:5961:5             
PossiblyFalsy                  TypeFlags              src/compiler/types.ts:6124:5             
NodeJs                         ModuleResolutionKind   src/compiler/types.ts:7045:5             
c                              CharacterCodes         src/compiler/types.ts:7553:5             
d                              CharacterCodes         src/compiler/types.ts:7554:5             
g                              CharacterCodes         src/compiler/types.ts:7557:5             
h                              CharacterCodes         src/compiler/types.ts:7558:5             
j                              CharacterCodes         src/compiler/types.ts:7560:5             
k                              CharacterCodes         src/compiler/types.ts:7561:5             
l                              CharacterCodes         src/compiler/types.ts:7562:5             
p                              CharacterCodes         src/compiler/types.ts:7566:5             
q                              CharacterCodes         src/compiler/types.ts:7567:5             
s                              CharacterCodes         src/compiler/types.ts:7569:5             
w                              CharacterCodes         src/compiler/types.ts:7573:5             
y                              CharacterCodes         src/compiler/types.ts:7575:5             
C                              CharacterCodes         src/compiler/types.ts:7580:5             
D                              CharacterCodes         src/compiler/types.ts:7581:5             
G                              CharacterCodes         src/compiler/types.ts:7584:5             
H                              CharacterCodes         src/compiler/types.ts:7585:5             
J                              CharacterCodes         src/compiler/types.ts:7587:5             
K                              CharacterCodes         src/compiler/types.ts:7588:5             
L                              CharacterCodes         src/compiler/types.ts:7589:5             
P                              CharacterCodes         src/compiler/types.ts:7593:5             
Q                              CharacterCodes         src/compiler/types.ts:7594:5             
R                              CharacterCodes         src/compiler/types.ts:7595:5             
S                              CharacterCodes         src/compiler/types.ts:7596:5             
U                              CharacterCodes         src/compiler/types.ts:7598:5             
V                              CharacterCodes         src/compiler/types.ts:7599:5             
W                              CharacterCodes         src/compiler/types.ts:7600:5             
Y                              CharacterCodes         src/compiler/types.ts:7602:5             
backspace                      CharacterCodes         src/compiler/types.ts:7636:5             
AssertTypeScript               TransformFlags         src/compiler/types.ts:7926:5             
AssertJsx                      TransformFlags         src/compiler/types.ts:7927:5             
AssertESNext                   TransformFlags         src/compiler/types.ts:7928:5             
AssertES2022                   TransformFlags         src/compiler/types.ts:7929:5             
AssertES2021                   TransformFlags         src/compiler/types.ts:7930:5             
AssertES2020                   TransformFlags         src/compiler/types.ts:7931:5             
AssertES2019                   TransformFlags         src/compiler/types.ts:7932:5             
AssertES2018                   TransformFlags         src/compiler/types.ts:7933:5             
AssertES2017                   TransformFlags         src/compiler/types.ts:7934:5             
AssertES2016                   TransformFlags         src/compiler/types.ts:7935:5             
AssertES2015                   TransformFlags         src/compiler/types.ts:7936:5             
AssertGenerator                TransformFlags         src/compiler/types.ts:7937:5             
AssertDestructuringAssignment  TransformFlags         src/compiler/types.ts:7938:5             
Choice                         SnippetKind            src/compiler/types.ts:8027:5             
Variable                       SnippetKind            src/compiler/types.ts:8028:5             
None                           JsxFlags               src/compiler/types.ts:907:5              
IntrinsicElement               JsxFlags               src/compiler/types.ts:913:5              
NotDelimited                   ListFormat             src/compiler/types.ts:9789:5             
SingleElement                  ListFormat             src/compiler/types.ts:9819:5             
ImportClauseEntries            ListFormat             src/compiler/types.ts:9836:24            
SourceFileStatements           ListFormat             src/compiler/types.ts:9857:5             
Default                        PragmaKindFlags        src/compiler/types.ts:9887:5             
None                           GetLiteralTextFlags    src/compiler/utilities.ts:1658:5         
Highest                        OperatorPrecedence     src/compiler/utilities.ts:5591:5         
terse                          LogLevel               src/server/utilitiesPublic.ts:16:5       
definition                     HighlightSpanKind      src/services/types.ts:1069:5             
fieldName                      SymbolDisplayPartKind  src/services/types.ts:1238:5             
regularExpressionLiteral       SymbolDisplayPartKind  src/services/types.ts:1256:5             
RegExpLiteral                  TokenClass             src/services/types.ts:1544:5             
link                           ScriptElementKind      src/services/types.ts:1695:5             
linkName                       ScriptElementKind      src/services/types.ts:1698:5             
linkText                       ScriptElementKind      src/services/types.ts:1701:5             
Invoked                        CompletionTriggerKind  src/services/types.ts:719:5              
TriggerCharacter               CompletionTriggerKind  src/services/types.ts:722:5              
None                           SemanticMeaning        src/services/utilities.ts:389:5
Duplicate exports (2)
local, default                            Herebyfile.mjs       
getJSDocTagCompletionDetails, getJSDo...  src/services/jsDoc.ts

Happy to receive any questions or feedback!

@jakebailey
Copy link
Member

let etwModule: typeof import("@microsoft/typescript-etw") | undefined;
shows the use of that typescript-etw, so it may be that knip isn't looking at import nodes? (I have not checked others)

@webpro
Copy link
Contributor Author

webpro commented Jan 2, 2024

let etwModule: typeof import("@microsoft/typescript-etw") | undefined;

shows the use of that typescript-etw, so it may be that knip isn't looking at import nodes? (I have not checked others)

It didn't look at ImportTypeNode nodes (typeof import()). As it didn't occur to me before they're not just import calls. I've just added support for that (to both stable and canary). Thanks for calling it out!

@sandersn sandersn added the Housekeeping Housekeeping PRs label Jan 2, 2024
package-lock.json Outdated Show resolved Hide resolved
knip.jsonc Outdated Show resolved Hide resolved
knip.jsonc Outdated Show resolved Hide resolved
@jakebailey
Copy link
Member

This change doesn't include the @internal removals; I think it'd be interesting to see those in full and make this PR a draft for further discussion.

@jakebailey jakebailey marked this pull request as draft January 4, 2024 19:06
@typescript-bot
Copy link
Collaborator

Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @mjbvz, @zkat, and @joj for you. Feel free to loop in other consumers/maintainers if necessary.

src/server/protocol.ts Outdated Show resolved Hide resolved
src/compiler/checker.ts Outdated Show resolved Hide resolved
@webpro
Copy link
Contributor Author

webpro commented Jan 4, 2024

This change doesn't include the @internal removals; I think it'd be interesting to see those in full and make this PR a draft for further discussion.

Pretty cool, I could just run this:

knip --include-entry-exports --experimental-tags=+internal --fix`

And then some Remove all unused in file in VS Code in various files.

Knip made 5 mistakes, I've put them back: 74a89a9

@webpro webpro force-pushed the remove-unused-exports branch 2 times, most recently from 28e0334 to 5360570 Compare January 4, 2024 23:03
@typescript-bot
Copy link
Collaborator

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page.

Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up.

@webpro
Copy link
Contributor Author

webpro commented Jun 19, 2024

Thanks, Jake! Just updated Knip, with less dependencies :)

@jakebailey
Copy link
Member

jakebailey commented Jun 25, 2024

Agh, unfortunately I think the change to start not complaining about things referenced in other exported members may have been overly conservative.

For example, if I restore this to emitHelpers.ts:

/** @internal */
export const decorateHelper: UnscopedEmitHelper = {

Then rerun knip, it doesn't complain even though it should. It seems like the analysis says "it's used via some other exported thing so ignore this too". But, it should only be considering that when a declaration is referenced from a position visible externally.

This is also why it's saying that parseBaseNodeFactory doesn't need to be ignored, even though it should still need to be.

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as needing changes (sorry) per the above so we don't accidentally merge this; the new change seems to more or less defeat most of the analysis for potentially-unexportable members.

# Conflicts:
#	package-lock.json
#	package.json
#	src/compiler/factory/emitHelpers.ts
@webpro
Copy link
Contributor Author

webpro commented Jun 27, 2024

Marking as needing changes (sorry) per the above so we don't accidentally merge this; the new change seems to more or less defeat most of the analysis for potentially-unexportable members.

I'm glad you did, in my enthusiasm I screwed up. Things should be good now.

@jakebailey
Copy link
Member

Nice, looking good!

@@ -1752,8 +1751,10 @@ function tryResolveJSModuleWorker(moduleName: string, initialDir: string, host:
/*conditions*/ undefined,
);
}

// knip applies the internal marker to _all_ declarations, not just the one overload.
Copy link
Member

@sheetalkamat sheetalkamat Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be changed. If not now, something to change on knip side for future.

@webpro
Copy link
Contributor Author

webpro commented Jun 27, 2024

This PR took a while, but has made Knip itself so much better, it's really great. Thanks for bearing with me :)

The TypeScript repo is also part of Knip's integration suite to prevent most nasty surprises/regressions: https://github.com/webpro-nl/knip/blob/main/.github/workflows/integration.yml#L101-L110 (I'll switch it to main)

@jakebailey
Copy link
Member

If you're looking for more work, I would also take a peek at https://npmgraph.js.org/?q=knip; shows a few deps that you may consider improving. It's a lot better than it was, though, so I don't think it's a problem here anymore.

@jakebailey
Copy link
Member

But obviously, thanks for all of your work here; going to do a final pass before we take things.

@webpro
Copy link
Contributor Author

webpro commented Jun 27, 2024

Would def love to fix up deps. It's mainly the bash-parser, which unfortunately is pretty challenging to replace (tree-sitter is still not an option: tree-sitter/tree-sitter-bash#188). Also, I get that a repo like this one does not need it at all, but it's an important part of Knip nonetheless. Also, tbqh, looking for funding.

@jakebailey jakebailey merged commit 752135e into microsoft:main Jun 27, 2024
29 checks passed
@webpro webpro deleted the remove-unused-exports branch June 28, 2024 04:57
@webpro webpro mentioned this pull request Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug Housekeeping Housekeeping PRs
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Remove unused exports & dead code (using Knip)
5 participants