Im not quite sure what is going on here but I can't access an interface that seems to be exported from the TSServer protocol (https://github.com/Microsoft/TypeScript/blob/master/src/server/protocol.ts)
To take a step back, I am working on a project where the code does this...
if (renameResults) {
if (renameResults.info.canRename) {
// do stuff ... no errors
}
} else {
this.printErr(renameResults.info.localizedErrorMessage);
}
If you look at the TSServer protocol for the type you will see that this is a union type of RenameInfoSuccess | RenameInfoFailure here
the code above gives me the error Property 'localizedErrorMessage' does not exist on type 'RenameInfo'. Property 'localizedErrorMessage' does not exist on type 'RenameInfoSuccess'
but it cannot be RenameInfoSuccess because I had already checked for it to be false, right? I have tried every combination I could think of checking the attributes of info but nothing has worked. I thought I would try to get at the interface and use as or instanceof but I cannot seem to import the interface any way either....
How can I make the compiler happy here?
EDIT: added another line that made the typecheck more precise