mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Remove unnecessary internal tags, handle bad input
This commit is contained in:
parent
42dc4155ce
commit
9f1e389441
@ -622,6 +622,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
positionToLineOffset(position: number): protocol.Location {
|
||||
failIfInvalidPosition(position);
|
||||
const location = this.textStorage.positionToLineOffset(position);
|
||||
failIfInvalidLocation(location);
|
||||
return location;
|
||||
@ -645,7 +646,11 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
function failIfInvalidPosition(position: number) {
|
||||
Debug.assert(typeof position === "number", `Expected position ${position} to be a number.`);
|
||||
Debug.assert(position >= 0, `Expected position to be non-negative.`);
|
||||
}
|
||||
|
||||
function failIfInvalidLocation(location: protocol.Location) {
|
||||
Debug.assert(typeof location.line === "number", `Expected line ${location.line} to be a number.`);
|
||||
Debug.assert(typeof location.offset === "number", `Expected offset ${location.offset} to be a number.`);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user