@@ -16,11 +16,14 @@ export class Printer {
1616 private printUnionOrIntersection (
1717 type : ts . UnionOrIntersectionType ,
1818 separator : string ,
19+ isPropertyBlacklisted : ( prop : string ) => boolean ,
1920 inner : boolean ,
2021 ) : string {
2122 return [
2223 ...new Set (
23- type . types . map ( ( t ) => this . printType ( t , inner ) ) . filter ( Boolean ) ,
24+ type . types
25+ . map ( ( t ) => this . printType ( t , isPropertyBlacklisted , inner ) )
26+ . filter ( Boolean ) ,
2427 ) ,
2528 ] . join ( separator ) ;
2629 }
@@ -29,13 +32,17 @@ export class Printer {
2932 return ! ! ( symbol . flags & ts . SymbolFlags . Optional ) ;
3033 }
3134
32- private printConditionType ( type : ts . ConditionalType , inner : boolean ) : string {
35+ private printConditionType (
36+ type : ts . ConditionalType ,
37+ isPropertyBlacklisted : ( prop : string ) => boolean ,
38+ inner : boolean ,
39+ ) : string {
3340 const decl = type . root . node ;
3441 const { trueType, falseType } = decl ;
3542 const trueTypeNode = this . checker . getTypeAtLocation ( trueType ) ;
3643 const falseTypeNode = this . checker . getTypeAtLocation ( falseType ) ;
3744
38- return `${ this . printType ( trueTypeNode , inner ) } | ${ this . printType ( falseTypeNode , inner ) } ` ;
45+ return `${ this . printType ( trueTypeNode , isPropertyBlacklisted , inner ) } | ${ this . printType ( falseTypeNode , isPropertyBlacklisted , inner ) } ` ;
3946 }
4047
4148 private printPrimitiveType ( type : ts . Type ) : string {
@@ -58,11 +65,25 @@ export class Printer {
5865 return "" ;
5966 }
6067
61- private printType ( type : ts . Type , inner = false ) : string {
68+ private printType (
69+ type : ts . Type ,
70+ isPropertyBlacklisted : ( prop : string ) => boolean ,
71+ inner = false ,
72+ ) : string {
6273 if ( type . isUnion ( ) ) {
63- return this . printUnionOrIntersection ( type , " | " , inner ) ;
74+ return this . printUnionOrIntersection (
75+ type ,
76+ " | " ,
77+ isPropertyBlacklisted ,
78+ inner ,
79+ ) ;
6480 } else if ( type . isIntersection ( ) ) {
65- return this . printUnionOrIntersection ( type , " & " , inner ) ;
81+ return this . printUnionOrIntersection (
82+ type ,
83+ " & " ,
84+ isPropertyBlacklisted ,
85+ inner ,
86+ ) ;
6687 }
6788 if ( this . checker . isArrayType ( type ) ) {
6889 return "Array" ;
@@ -86,8 +107,13 @@ export class Printer {
86107 > = { } ;
87108 for ( const prop of properties ) {
88109 const propType = this . checker . getTypeOfSymbol ( prop ) ;
89- props [ prop . getName ( ) ] = {
90- value : this . printType ( propType , true ) ,
110+ const name = prop . getName ( ) ;
111+ if ( isPropertyBlacklisted ( name ) ) {
112+ continue ;
113+ }
114+
115+ props [ name ] = {
116+ value : this . printType ( propType , isPropertyBlacklisted , true ) ,
91117 isOptional : this . isSymbolOptional ( prop ) ,
92118 } ;
93119 }
@@ -113,7 +139,11 @@ export class Printer {
113139 } else if ( type . flags & ts . TypeFlags . Undefined ) {
114140 return "" ;
115141 } else if ( type . flags & ts . TypeFlags . Conditional ) {
116- return this . printConditionType ( type as ts . ConditionalType , inner ) ;
142+ return this . printConditionType (
143+ type as ts . ConditionalType ,
144+ isPropertyBlacklisted ,
145+ inner ,
146+ ) ;
117147 } else if ( type . isTypeParameter ( ) ) {
118148 const symbol = type . getSymbol ( ) ;
119149 const decl = symbol ?. declarations ?. [ 0 ] ;
@@ -126,16 +156,19 @@ export class Printer {
126156 }
127157 const refType = this . checker . getTypeAtLocation ( ref ) ;
128158
129- return this . printType ( refType , inner ) ;
159+ return this . printType ( refType , isPropertyBlacklisted , inner ) ;
130160 }
131161
132162 return this . typeToString ( type ) ;
133163 }
134164
135- public printPropsTypeArg ( node : ts . Node ) : string {
165+ public printPropsTypeArg (
166+ node : ts . Node ,
167+ isPropertyBlacklisted : ( prop : string ) => boolean ,
168+ ) : string {
136169 const type = this . checker . getTypeAtLocation ( node ) ;
137170
138- return this . printType ( type ) ;
171+ return this . printType ( type , isPropertyBlacklisted ) ;
139172 }
140173
141174 private printEventsByCallSignatures (
0 commit comments