Skip to content

Commit 3013116

Browse files
committed
Remove null checks
1 parent 30b57e0 commit 3013116

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

server/src/utils.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -628,10 +628,7 @@ export let getCompiledFilePath = (
628628
}
629629

630630
// Normalize the path before returning
631-
const normalizedResult = normalizePath(result);
632-
if (normalizedResult == null) {
633-
return error;
634-
}
631+
const normalizedResult = normalizePath(result)!;
635632

636633
return {
637634
kind: "success",
@@ -733,12 +730,7 @@ let parseFileAndRange = (fileAndRange: string) => {
733730
let match = trimmedFileAndRange.match(regex);
734731
if (match === null) {
735732
// no location! Though LSP insist that we provide at least a dummy location
736-
const normalizedPath = normalizePath(trimmedFileAndRange);
737-
if (normalizedPath == null) {
738-
// If we can't normalize the file path, throw an error
739-
// This should never happen in practice, but we need to handle it
740-
throw new Error(`Failed to normalize file path: ${trimmedFileAndRange}`);
741-
}
733+
const normalizedPath = normalizePath(trimmedFileAndRange)!;
742734
return {
743735
file: pathToURI(normalizedPath),
744736
range: {
@@ -784,12 +776,7 @@ let parseFileAndRange = (fileAndRange: string) => {
784776
end: { line: parseInt(endLine) - 1, character: parseInt(endChar) },
785777
};
786778
}
787-
const normalizedFile = normalizePath(file);
788-
if (normalizedFile == null) {
789-
// If we can't normalize the file path, throw an error
790-
// This should never happen in practice, but we need to handle it
791-
throw new Error(`Failed to normalize file path: ${file}`);
792-
}
779+
const normalizedFile = normalizePath(file)!;
793780
return {
794781
file: pathToURI(normalizedFile),
795782
range,

0 commit comments

Comments
 (0)