File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ exports.load = function ({ application }: { application: Application }) {
6868 . getSymbolsInScope ( node , TypeScript . SymbolFlags . ModuleMember )
6969 . filter (
7070 ( symbol ) =>
71- symbol . getDeclarations ( ) ?. some ( ( d ) => d . parent === node ) &&
71+ isInDocumentableScope ( symbol , node ) &&
7272 ! exportedSymbols . includes ( symbol )
7373 )
7474
@@ -83,3 +83,24 @@ exports.load = function ({ application }: { application: Application }) {
8383 }
8484 }
8585}
86+
87+ function isInDocumentableScope ( symbol : TypeScript . Symbol , node : TypeScript . Node ) {
88+ for ( const decl of symbol . getDeclarations ( ) || [ ] ) {
89+ // Case 1: Included in this namespace/source file
90+ if ( decl . parent === node ) return true
91+
92+ // Case 2: Within `declare global {}`
93+ // We need to check isSourceFile here as well because otherwise it will be picked up
94+ // in the scope of namespaces while we should be picking it up only in the first case
95+ if (
96+ TypeScript . isSourceFile ( node ) &&
97+ TypeScript . isModuleBlock ( decl . parent ) &&
98+ decl . parent . parent . name . getText ( ) === "global"
99+ ) {
100+ return true
101+ }
102+ }
103+
104+ return false
105+ }
106+
You can’t perform that action at this time.
0 commit comments