@@ -180,7 +180,7 @@ export class TSDocConfigFile {
180
180
const tagDefinition : TSDocTagDefinition = new TSDocTagDefinition ( parameters ) ;
181
181
182
182
if ( this . _tagDefinitionNames . has ( tagDefinition . tagNameWithUpperCase ) ) {
183
- throw new Error ( `A tag defintion was already added with the tag name "${ parameters . tagName } "` ) ;
183
+ throw new Error ( `A tag definition was already added with the tag name "${ parameters . tagName } "` ) ;
184
184
}
185
185
this . _tagDefinitionNames . add ( tagDefinition . tagName ) ;
186
186
@@ -209,7 +209,7 @@ export class TSDocConfigFile {
209
209
textRange : TextRange . empty ,
210
210
} ) ;
211
211
}
212
- this . _tagDefinitionNames . add ( tagDefinition . tagName ) ;
212
+ this . _tagDefinitionNames . add ( tagDefinition . tagNameWithUpperCase ) ;
213
213
214
214
this . _tagDefinitions . push ( tagDefinition ) ;
215
215
}
@@ -381,7 +381,19 @@ export class TSDocConfigFile {
381
381
const configJsonContent : string = fs . readFileSync ( this . _filePath ) . toString ( ) ;
382
382
this . _fileMTime = fs . statSync ( this . _filePath ) . mtimeMs ;
383
383
384
- const configJson : IConfigJson = jju . parse ( configJsonContent , { mode : 'cjson' } ) ;
384
+ let configJson : IConfigJson ;
385
+ try {
386
+ configJson = jju . parse ( configJsonContent , { mode : 'cjson' } ) ;
387
+ } catch ( e ) {
388
+ this . log . addMessage (
389
+ new ParserMessage ( {
390
+ messageId : TSDocMessageId . ConfigInvalidJson ,
391
+ messageText : 'Error parsing JSON input: ' + e . message ,
392
+ textRange : TextRange . empty ,
393
+ } )
394
+ ) ;
395
+ return ;
396
+ }
385
397
386
398
this . _loadJsonObject ( configJson ) ;
387
399
@@ -446,6 +458,12 @@ export class TSDocConfigFile {
446
458
/**
447
459
* Calls `TSDocConfigFile.findConfigPathForFolder()` to find the relevant tsdoc.json config file, if one exists.
448
460
* Then calls `TSDocConfigFile.findConfigPathForFolder()` to return the loaded result.
461
+ *
462
+ * @remarks
463
+ * This API does not report loading errors by throwing exceptions. Instead, the caller is expected to check
464
+ * for errors using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log},
465
+ * or {@link TSDocConfigFile.getErrorSummary}.
466
+ *
449
467
* @param folderPath - the path to a folder where the search should start
450
468
*/
451
469
public static loadForFolder ( folderPath : string ) : TSDocConfigFile {
@@ -455,6 +473,12 @@ export class TSDocConfigFile {
455
473
456
474
/**
457
475
* Loads the specified tsdoc.json and any base files that it refers to using the "extends" option.
476
+ *
477
+ * @remarks
478
+ * This API does not report loading errors by throwing exceptions. Instead, the caller is expected to check
479
+ * for errors using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log},
480
+ * or {@link TSDocConfigFile.getErrorSummary}.
481
+ *
458
482
* @param tsdocJsonFilePath - the path to the tsdoc.json config file
459
483
*/
460
484
public static loadFile ( tsdocJsonFilePath : string ) : TSDocConfigFile {
@@ -469,6 +493,10 @@ export class TSDocConfigFile {
469
493
*
470
494
* @remarks
471
495
* The serialized object has the same structure as `tsdoc.json`; however the `"extends"` field is not allowed.
496
+ *
497
+ * This API does not report loading errors by throwing exceptions. Instead, the caller is expected to check
498
+ * for errors using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log},
499
+ * or {@link TSDocConfigFile.getErrorSummary}.
472
500
*/
473
501
public static loadFromObject ( jsonObject : unknown ) : TSDocConfigFile {
474
502
const configFile : TSDocConfigFile = new TSDocConfigFile ( ) ;
@@ -484,6 +512,11 @@ export class TSDocConfigFile {
484
512
485
513
/**
486
514
* Initializes a TSDocConfigFile object using the state from the provided `TSDocConfiguration` object.
515
+ *
516
+ * @remarks
517
+ * This API does not report loading errors by throwing exceptions. Instead, the caller is expected to check
518
+ * for errors using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log},
519
+ * or {@link TSDocConfigFile.getErrorSummary}.
487
520
*/
488
521
public static loadFromParser ( configuration : TSDocConfiguration ) : TSDocConfigFile {
489
522
const configFile : TSDocConfigFile = new TSDocConfigFile ( ) ;
@@ -607,6 +640,10 @@ export class TSDocConfigFile {
607
640
/**
608
641
* Applies the settings from this config file to a TSDoc parser configuration.
609
642
* Any `extendsFile` settings will also applied.
643
+ *
644
+ * @remarks
645
+ * Additional validation is performed during this operation. The caller is expected to check for errors
646
+ * using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log}, or {@link TSDocConfigFile.getErrorSummary}.
610
647
*/
611
648
public configureParser ( configuration : TSDocConfiguration ) : void {
612
649
if ( this . _getNoStandardTagsWithExtends ( ) ) {
@@ -622,6 +659,10 @@ export class TSDocConfigFile {
622
659
623
660
/**
624
661
* This is the same as {@link configureParser}, but it preserves any previous state.
662
+ *
663
+ * @remarks
664
+ * Additional validation is performed during this operation. The caller is expected to check for errors
665
+ * using {@link TSDocConfigFile.hasErrors}, {@link TSDocConfigFile.log}, or {@link TSDocConfigFile.getErrorSummary}.
625
666
*/
626
667
public updateParser ( configuration : TSDocConfiguration ) : void {
627
668
// First apply the base config files
0 commit comments