@@ -227,6 +227,10 @@ export class Evaluator {
227
227
return entry ;
228
228
}
229
229
230
+ function isFoldableError ( value : any ) : value is MetadataError {
231
+ return ! t . options . verboseInvalidExpression && isMetadataError ( value ) ;
232
+ }
233
+
230
234
switch ( node . kind ) {
231
235
case ts . SyntaxKind . ObjectLiteralExpression :
232
236
let obj : { [ name : string ] : any } = { } ;
@@ -241,14 +245,14 @@ export class Evaluator {
241
245
quoted . push ( name ) ;
242
246
}
243
247
const propertyName = this . nameOf ( assignment . name ) ;
244
- if ( isMetadataError ( propertyName ) ) {
248
+ if ( isFoldableError ( propertyName ) ) {
245
249
error = propertyName ;
246
250
return true ;
247
251
}
248
252
const propertyValue = isPropertyAssignment ( assignment ) ?
249
253
this . evaluateNode ( assignment . initializer ) :
250
254
{ __symbolic : 'reference' , name : propertyName } ;
251
- if ( isMetadataError ( propertyValue ) ) {
255
+ if ( isFoldableError ( propertyValue ) ) {
252
256
error = propertyValue ;
253
257
return true ; // Stop the forEachChild.
254
258
} else {
@@ -267,7 +271,7 @@ export class Evaluator {
267
271
const value = this . evaluateNode ( child ) ;
268
272
269
273
// Check for error
270
- if ( isMetadataError ( value ) ) {
274
+ if ( isFoldableError ( value ) ) {
271
275
error = value ;
272
276
return true ; // Stop the forEachChild.
273
277
}
@@ -299,14 +303,14 @@ export class Evaluator {
299
303
}
300
304
}
301
305
const args = callExpression . arguments . map ( arg => this . evaluateNode ( arg ) ) ;
302
- if ( args . some ( isMetadataError ) ) {
306
+ if ( ! this . options . verboseInvalidExpression && args . some ( isMetadataError ) ) {
303
307
return args . find ( isMetadataError ) ;
304
308
}
305
309
if ( this . isFoldable ( callExpression ) ) {
306
310
if ( isMethodCallOf ( callExpression , 'concat' ) ) {
307
311
const arrayValue = < MetadataValue [ ] > this . evaluateNode (
308
312
( < ts . PropertyAccessExpression > callExpression . expression ) . expression ) ;
309
- if ( isMetadataError ( arrayValue ) ) return arrayValue ;
313
+ if ( isFoldableError ( arrayValue ) ) return arrayValue ;
310
314
return arrayValue . concat ( args [ 0 ] ) ;
311
315
}
312
316
}
@@ -315,7 +319,7 @@ export class Evaluator {
315
319
return recordEntry ( args [ 0 ] , node ) ;
316
320
}
317
321
const expression = this . evaluateNode ( callExpression . expression ) ;
318
- if ( isMetadataError ( expression ) ) {
322
+ if ( isFoldableError ( expression ) ) {
319
323
return recordEntry ( expression , node ) ;
320
324
}
321
325
let result : MetadataSymbolicCallExpression = { __symbolic : 'call' , expression : expression } ;
@@ -326,7 +330,7 @@ export class Evaluator {
326
330
case ts . SyntaxKind . NewExpression :
327
331
const newExpression = < ts . NewExpression > node ;
328
332
const newArgs = newExpression . arguments . map ( arg => this . evaluateNode ( arg ) ) ;
329
- if ( newArgs . some ( isMetadataError ) ) {
333
+ if ( ! this . options . verboseInvalidExpression && newArgs . some ( isMetadataError ) ) {
330
334
return recordEntry ( newArgs . find ( isMetadataError ) , node ) ;
331
335
}
332
336
const newTarget = this . evaluateNode ( newExpression . expression ) ;
@@ -341,11 +345,11 @@ export class Evaluator {
341
345
case ts . SyntaxKind . PropertyAccessExpression : {
342
346
const propertyAccessExpression = < ts . PropertyAccessExpression > node ;
343
347
const expression = this . evaluateNode ( propertyAccessExpression . expression ) ;
344
- if ( isMetadataError ( expression ) ) {
348
+ if ( isFoldableError ( expression ) ) {
345
349
return recordEntry ( expression , node ) ;
346
350
}
347
351
const member = this . nameOf ( propertyAccessExpression . name ) ;
348
- if ( isMetadataError ( member ) ) {
352
+ if ( isFoldableError ( member ) ) {
349
353
return recordEntry ( member , node ) ;
350
354
}
351
355
if ( expression && this . isFoldable ( propertyAccessExpression . expression ) )
@@ -361,11 +365,11 @@ export class Evaluator {
361
365
case ts . SyntaxKind . ElementAccessExpression : {
362
366
const elementAccessExpression = < ts . ElementAccessExpression > node ;
363
367
const expression = this . evaluateNode ( elementAccessExpression . expression ) ;
364
- if ( isMetadataError ( expression ) ) {
368
+ if ( isFoldableError ( expression ) ) {
365
369
return recordEntry ( expression , node ) ;
366
370
}
367
371
const index = this . evaluateNode ( elementAccessExpression . argumentExpression ) ;
368
- if ( isMetadataError ( expression ) ) {
372
+ if ( isFoldableError ( expression ) ) {
369
373
return recordEntry ( expression , node ) ;
370
374
}
371
375
if ( this . isFoldable ( elementAccessExpression . expression ) &&
@@ -404,15 +408,15 @@ export class Evaluator {
404
408
} else {
405
409
const identifier = < ts . Identifier > typeNameNode ;
406
410
const symbol = this . symbols . resolve ( identifier . text ) ;
407
- if ( isMetadataError ( symbol ) || isMetadataSymbolicReferenceExpression ( symbol ) ) {
411
+ if ( isFoldableError ( symbol ) || isMetadataSymbolicReferenceExpression ( symbol ) ) {
408
412
return recordEntry ( symbol , node ) ;
409
413
}
410
414
return recordEntry (
411
415
errorSymbol ( 'Could not resolve type' , node , { typeName : identifier . text } ) , node ) ;
412
416
}
413
417
} ;
414
418
const typeReference = getReference ( typeNameNode ) ;
415
- if ( isMetadataError ( typeReference ) ) {
419
+ if ( isFoldableError ( typeReference ) ) {
416
420
return recordEntry ( typeReference , node ) ;
417
421
}
418
422
if ( ! isMetadataModuleReferenceExpression ( typeReference ) &&
0 commit comments