Firstly, I described the type File by manually enumerating its possible values as type literals. Then I specified the type of selectedFile as the union of File and null to set the initial value to null.
type File = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H";
let selectedFile = ref<File | null>(null);
function move() {
let newPosition = new Position(selectedFile, selectedRank);
// ...
}
And the error I get:
let selectedFile: Ref<File | null>
Argument of type 'Ref<File | null>' is not assignable to parameter of type
'File'.ts(2345)