@@ -227,6 +227,10 @@ export class Evaluator {
227227 return entry ;
228228 }
229229
230+ function isFoldableError ( value : any ) : value is MetadataError {
231+ return ! t . options . verboseInvalidExpression && isMetadataError ( value ) ;
232+ }
233+
230234 switch ( node . kind ) {
231235 case ts . SyntaxKind . ObjectLiteralExpression :
232236 let obj : { [ name : string ] : any } = { } ;
@@ -241,14 +245,14 @@ export class Evaluator {
241245 quoted . push ( name ) ;
242246 }
243247 const propertyName = this . nameOf ( assignment . name ) ;
244- if ( isMetadataError ( propertyName ) ) {
248+ if ( isFoldableError ( propertyName ) ) {
245249 error = propertyName ;
246250 return true ;
247251 }
248252 const propertyValue = isPropertyAssignment ( assignment ) ?
249253 this . evaluateNode ( assignment . initializer ) :
250254 { __symbolic : 'reference' , name : propertyName } ;
251- if ( isMetadataError ( propertyValue ) ) {
255+ if ( isFoldableError ( propertyValue ) ) {
252256 error = propertyValue ;
253257 return true ; // Stop the forEachChild.
254258 } else {
@@ -267,7 +271,7 @@ export class Evaluator {
267271 const value = this . evaluateNode ( child ) ;
268272
269273 // Check for error
270- if ( isMetadataError ( value ) ) {
274+ if ( isFoldableError ( value ) ) {
271275 error = value ;
272276 return true ; // Stop the forEachChild.
273277 }
@@ -299,14 +303,14 @@ export class Evaluator {
299303 }
300304 }
301305 const args = callExpression . arguments . map ( arg => this . evaluateNode ( arg ) ) ;
302- if ( args . some ( isMetadataError ) ) {
306+ if ( ! this . options . verboseInvalidExpression && args . some ( isMetadataError ) ) {
303307 return args . find ( isMetadataError ) ;
304308 }
305309 if ( this . isFoldable ( callExpression ) ) {
306310 if ( isMethodCallOf ( callExpression , 'concat' ) ) {
307311 const arrayValue = < MetadataValue [ ] > this . evaluateNode (
308312 ( < ts . PropertyAccessExpression > callExpression . expression ) . expression ) ;
309- if ( isMetadataError ( arrayValue ) ) return arrayValue ;
313+ if ( isFoldableError ( arrayValue ) ) return arrayValue ;
310314 return arrayValue . concat ( args [ 0 ] ) ;
311315 }
312316 }
@@ -315,7 +319,7 @@ export class Evaluator {
315319 return recordEntry ( args [ 0 ] , node ) ;
316320 }
317321 const expression = this . evaluateNode ( callExpression . expression ) ;
318- if ( isMetadataError ( expression ) ) {
322+ if ( isFoldableError ( expression ) ) {
319323 return recordEntry ( expression , node ) ;
320324 }
321325 let result : MetadataSymbolicCallExpression = { __symbolic : 'call' , expression : expression } ;
@@ -326,7 +330,7 @@ export class Evaluator {
326330 case ts . SyntaxKind . NewExpression :
327331 const newExpression = < ts . NewExpression > node ;
328332 const newArgs = newExpression . arguments . map ( arg => this . evaluateNode ( arg ) ) ;
329- if ( newArgs . some ( isMetadataError ) ) {
333+ if ( ! this . options . verboseInvalidExpression && newArgs . some ( isMetadataError ) ) {
330334 return recordEntry ( newArgs . find ( isMetadataError ) , node ) ;
331335 }
332336 const newTarget = this . evaluateNode ( newExpression . expression ) ;
@@ -341,11 +345,11 @@ export class Evaluator {
341345 case ts . SyntaxKind . PropertyAccessExpression : {
342346 const propertyAccessExpression = < ts . PropertyAccessExpression > node ;
343347 const expression = this . evaluateNode ( propertyAccessExpression . expression ) ;
344- if ( isMetadataError ( expression ) ) {
348+ if ( isFoldableError ( expression ) ) {
345349 return recordEntry ( expression , node ) ;
346350 }
347351 const member = this . nameOf ( propertyAccessExpression . name ) ;
348- if ( isMetadataError ( member ) ) {
352+ if ( isFoldableError ( member ) ) {
349353 return recordEntry ( member , node ) ;
350354 }
351355 if ( expression && this . isFoldable ( propertyAccessExpression . expression ) )
@@ -361,11 +365,11 @@ export class Evaluator {
361365 case ts . SyntaxKind . ElementAccessExpression : {
362366 const elementAccessExpression = < ts . ElementAccessExpression > node ;
363367 const expression = this . evaluateNode ( elementAccessExpression . expression ) ;
364- if ( isMetadataError ( expression ) ) {
368+ if ( isFoldableError ( expression ) ) {
365369 return recordEntry ( expression , node ) ;
366370 }
367371 const index = this . evaluateNode ( elementAccessExpression . argumentExpression ) ;
368- if ( isMetadataError ( expression ) ) {
372+ if ( isFoldableError ( expression ) ) {
369373 return recordEntry ( expression , node ) ;
370374 }
371375 if ( this . isFoldable ( elementAccessExpression . expression ) &&
@@ -404,15 +408,15 @@ export class Evaluator {
404408 } else {
405409 const identifier = < ts . Identifier > typeNameNode ;
406410 const symbol = this . symbols . resolve ( identifier . text ) ;
407- if ( isMetadataError ( symbol ) || isMetadataSymbolicReferenceExpression ( symbol ) ) {
411+ if ( isFoldableError ( symbol ) || isMetadataSymbolicReferenceExpression ( symbol ) ) {
408412 return recordEntry ( symbol , node ) ;
409413 }
410414 return recordEntry (
411415 errorSymbol ( 'Could not resolve type' , node , { typeName : identifier . text } ) , node ) ;
412416 }
413417 } ;
414418 const typeReference = getReference ( typeNameNode ) ;
415- if ( isMetadataError ( typeReference ) ) {
419+ if ( isFoldableError ( typeReference ) ) {
416420 return recordEntry ( typeReference , node ) ;
417421 }
418422 if ( ! isMetadataModuleReferenceExpression ( typeReference ) &&
0 commit comments