@@ -4510,24 +4510,23 @@ const enum State {
4510
4510
inObjectMarker
4511
4511
}
4512
4512
4513
- function reportError ( fileName : string , line : number , col : number , message : string ) {
4513
+ function reportError ( fileName : string , line : number , col : number , message : string ) : never {
4514
4514
const errorMessage = fileName + "(" + line + "," + col + "): " + message ;
4515
4515
throw new Error ( errorMessage ) ;
4516
4516
}
4517
4517
4518
4518
function recordObjectMarker ( fileName : string , location : LocationInformation , text : string , markerMap : Map < string , Marker > , markers : Marker [ ] ) : Marker | undefined {
4519
- let markerValue : any ;
4519
+ let markerValue ;
4520
4520
try {
4521
4521
// Attempt to parse the marker value as JSON
4522
- markerValue = JSON . parse ( "{ " + text + " }" ) ;
4522
+ markerValue = JSON . parse ( "{ " + text + " }" ) as { name ?: unknown } ;
4523
4523
}
4524
4524
catch ( e ) {
4525
4525
reportError ( fileName , location . sourceLine , location . sourceColumn , "Unable to parse marker text " + e . message ) ;
4526
4526
}
4527
4527
4528
4528
if ( markerValue === undefined ) {
4529
4529
reportError ( fileName , location . sourceLine , location . sourceColumn , "Object markers can not be empty" ) ;
4530
- return undefined ;
4531
4530
}
4532
4531
4533
4532
const marker : Marker = {
@@ -4537,7 +4536,7 @@ function recordObjectMarker(fileName: string, location: LocationInformation, tex
4537
4536
} ;
4538
4537
4539
4538
// Object markers can be anonymous
4540
- if ( markerValue . name ) {
4539
+ if ( typeof markerValue . name === "string" ) {
4541
4540
markerMap . set ( markerValue . name , marker ) ;
4542
4541
}
4543
4542
@@ -4556,7 +4555,6 @@ function recordMarker(fileName: string, location: LocationInformation, name: str
4556
4555
if ( markerMap . has ( name ) ) {
4557
4556
const message = "Marker '" + name + "' is duplicated in the source file contents." ;
4558
4557
reportError ( marker . fileName , location . sourceLine , location . sourceColumn , message ) ;
4559
- return undefined ;
4560
4558
}
4561
4559
else {
4562
4560
markerMap . set ( name , marker ) ;
@@ -4623,7 +4621,7 @@ function parseFileContent(content: string, fileName: string, markerMap: Map<stri
4623
4621
// found a range end
4624
4622
const rangeStart = openRanges . pop ( ) ;
4625
4623
if ( ! rangeStart ) {
4626
- throw reportError ( fileName , line , column , "Found range end with no matching start." ) ;
4624
+ reportError ( fileName , line , column , "Found range end with no matching start." ) ;
4627
4625
}
4628
4626
4629
4627
const range : Range = {
0 commit comments