File tree Expand file tree Collapse file tree 3 files changed +96
-2
lines changed
Expand file tree Collapse file tree 3 files changed +96
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' fumadocs-typescript ' : patch
3+ ---
4+
5+ Fix private class members
Original file line number Diff line number Diff line change @@ -111,12 +111,22 @@ export function generate(
111111 . getType ( )
112112 . getProperties ( )
113113 . map ( ( prop ) => getDocEntry ( prop , entryContext ) )
114- . filter ( ( entry ) => allowInternal || ! ( 'internal' in entry . tags ) ) ,
114+ . filter (
115+ ( entry ) => entry && ( allowInternal || ! ( 'internal' in entry . tags ) ) ,
116+ ) as DocEntry [ ] ,
115117 } ;
116118}
117119
118- function getDocEntry ( prop : TsSymbol , context : EntryContext ) : DocEntry {
120+ function getDocEntry (
121+ prop : TsSymbol ,
122+ context : EntryContext ,
123+ ) : DocEntry | undefined {
119124 const { transform, program } = context ;
125+
126+ if ( context . type . isClass ( ) && prop . getName ( ) . startsWith ( '#' ) ) {
127+ return ;
128+ }
129+
120130 const subType = program
121131 . getTypeChecker ( )
122132 . getTypeOfSymbolAtLocation ( prop , context . declaration ) ;
Original file line number Diff line number Diff line change 1+ import { expect , test } from 'vitest' ;
2+ import { generateDocumentation } from '@/generate/base' ;
3+
4+ test ( 'class members' , ( ) => {
5+ const out = generateDocumentation (
6+ 'index.ts' ,
7+ 'MyClass' ,
8+ `
9+ export class MyClass {
10+ #name: string;
11+ private test: string;
12+ age: number;
13+
14+ constructor(name: string) {
15+ this.#name = name;
16+ }
17+ }
18+ ` ,
19+ ) ;
20+
21+ expect ( out ) . toMatchInlineSnapshot ( `
22+ [
23+ {
24+ "description": "",
25+ "entries": [
26+ {
27+ "description": "",
28+ "name": "test",
29+ "tags": {},
30+ "type": "string",
31+ },
32+ {
33+ "description": "",
34+ "name": "age",
35+ "tags": {},
36+ "type": "number",
37+ },
38+ ],
39+ "name": "MyClass",
40+ },
41+ ]
42+ ` ) ;
43+ } ) ;
44+
45+ test ( 'interface members' , ( ) => {
46+ const out = generateDocumentation (
47+ 'index.ts' ,
48+ 'MyInterface' ,
49+ `
50+ export interface MyInterface {
51+ "#name": string;
52+ age: number
53+ }
54+ ` ,
55+ ) ;
56+
57+ expect ( out ) . toMatchInlineSnapshot ( `
58+ [
59+ {
60+ "description": "",
61+ "entries": [
62+ {
63+ "description": "",
64+ "name": "#name",
65+ "tags": {},
66+ "type": "string",
67+ },
68+ {
69+ "description": "",
70+ "name": "age",
71+ "tags": {},
72+ "type": "number",
73+ },
74+ ],
75+ "name": "MyInterface",
76+ },
77+ ]
78+ ` ) ;
79+ } ) ;
You can’t perform that action at this time.
0 commit comments