Skip to content

Commit 9f1e389

Browse files
author
Ben Lichtman
committed
Remove unnecessary internal tags, handle bad input
1 parent 42dc415 commit 9f1e389

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/server/scriptInfo.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ namespace ts.server {
622622
}
623623

624624
positionToLineOffset(position: number): protocol.Location {
625+
failIfInvalidPosition(position);
625626
const location = this.textStorage.positionToLineOffset(position);
626627
failIfInvalidLocation(location);
627628
return location;
@@ -645,7 +646,11 @@ namespace ts.server {
645646
}
646647
}
647648

648-
/*@internal*/
649+
function failIfInvalidPosition(position: number) {
650+
Debug.assert(typeof position === "number", `Expected position ${position} to be a number.`);
651+
Debug.assert(position >= 0, `Expected position to be non-negative.`);
652+
}
653+
649654
function failIfInvalidLocation(location: protocol.Location) {
650655
Debug.assert(typeof location.line === "number", `Expected line ${location.line} to be a number.`);
651656
Debug.assert(typeof location.offset === "number", `Expected offset ${location.offset} to be a number.`);

0 commit comments

Comments
 (0)