Refactor browser extension FileInfo to disallow invalid states at the type level
Created by: felixfbecker
The FileInfo
interface in the browser extension is a core part of the code intel logic. It has lots of properties that depend on each other. For example, all the base
-prefixed properties should either all exist or none of them should. The headHasContent
boolean is redundant to the content
property (except that we seem to set content
to an empty string even if an error happened: #3085 (closed)). These invalid possible states were the source of bugs in the Bitbucket integration.
It should disallow invalid states, something like this:
type DiffFileInfo = { head: FileInfo } | { base: FileInfo } | { head: FileInfo, base: FileInfo }
interface FileInfo {
content
commitID
repoName
filePath
}