File tree Expand file tree Collapse file tree 4 files changed +10
-3
lines changed Expand file tree Collapse file tree 4 files changed +10
-3
lines changed Original file line number Diff line number Diff line change
1
+ { "releases" : [{ "name" : " kind2string" , "type" : " patch" }], "dependents" : [] }
Original file line number Diff line number Diff line change
1
+ Introduces flag "EXTRACT_REACT_TYPES_HIDE_ERRORS" to suppress errors
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import * as K from 'extract-react-types'
14
14
import { resolveToLast , resolveFromGeneric , reduceToObj } from './utils' ;
15
15
16
16
const unaryWhiteList = [ '-' , '+' , '!' ] ;
17
+ const hideErrors = ! ! process . env . EXTRACT_REACT_TYPES_HIDE_ERRORS ;
17
18
18
19
function mapConvertAndJoin ( array , joiner = ', ' ) {
19
20
if ( ! Array . isArray ( array ) ) return '' ;
@@ -185,7 +186,7 @@ const converters = {
185
186
const object = resolveToLast ( type . object ) ;
186
187
const property = convert ( type . property ) ;
187
188
188
- if ( ! object ) {
189
+ if ( ! object && ! hideErrors ) {
189
190
console . error ( 'Object property does not exist on this member expression' ) ;
190
191
return '' ;
191
192
}
Original file line number Diff line number Diff line change
1
+ const hideErrors = ! ! process . env . EXTRACT_REACT_TYPES_HIDE_ERRORS ;
2
+
1
3
export function resolveToLast ( type /*: MemberExpression | Obj | Id*/ ) {
2
4
switch ( type . kind ) {
3
5
case 'id' :
@@ -7,8 +9,10 @@ export function resolveToLast(type /*: MemberExpression | Obj | Id*/) {
7
9
case 'memberExpression' :
8
10
return resolveToLast ( type . object ) ;
9
11
default :
10
- /* eslint-disable-next-line no-console */
11
- console . error ( `Unexpected initial type of member expression` , JSON . stringify ( type ) ) ;
12
+ if ( hideErrors ) {
13
+ /* eslint-disable-next-line no-console */
14
+ console . error ( `Unexpected initial type of member expression` , JSON . stringify ( type ) ) ;
15
+ }
12
16
break ;
13
17
}
14
18
}
You can’t perform that action at this time.
0 commit comments