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'
1414import { resolveToLast , resolveFromGeneric , reduceToObj } from './utils' ;
1515
1616const unaryWhiteList = [ '-' , '+' , '!' ] ;
17+ const hideErrors = ! ! process . env . EXTRACT_REACT_TYPES_HIDE_ERRORS ;
1718
1819function mapConvertAndJoin ( array , joiner = ', ' ) {
1920 if ( ! Array . isArray ( array ) ) return '' ;
@@ -185,7 +186,7 @@ const converters = {
185186 const object = resolveToLast ( type . object ) ;
186187 const property = convert ( type . property ) ;
187188
188- if ( ! object ) {
189+ if ( ! object && ! hideErrors ) {
189190 console . error ( 'Object property does not exist on this member expression' ) ;
190191 return '' ;
191192 }
Original file line number Diff line number Diff line change 1+ const hideErrors = ! ! process . env . EXTRACT_REACT_TYPES_HIDE_ERRORS ;
2+
13export function resolveToLast ( type /*: MemberExpression | Obj | Id*/ ) {
24 switch ( type . kind ) {
35 case 'id' :
@@ -7,8 +9,10 @@ export function resolveToLast(type /*: MemberExpression | Obj | Id*/) {
79 case 'memberExpression' :
810 return resolveToLast ( type . object ) ;
911 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+ }
1216 break ;
1317 }
1418}
You can’t perform that action at this time.
0 commit comments