-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
TypeScript Version: 2.1.4
This code in my VS Code extension has stopped compiling (without changes) recently.
if (context.globalState.get(stateKey, false) !== true)
// blah
It returns the error:
src/user_config_prompts.ts(17,6):
error TS2365: Operator '!==' cannot be applied to types 'false' and 'true'.
The full source is here and the build output here.
It seems like TypeScript has decided that the call to get
can only return false, and therefore this comparison is bad; however I don't believe that's true - this method access stored state, so I can put some value in it and then reload my extension and it would receive the stored value.
This may be the same as #12772, but the response is confusing to me:
the function expression is not considered part of the flow, since it is not guaranteed to execute
This logic seems flawed - you can't assume something can never have a certain value because it might not be called; surely you have to assume it might have that value because you do not know if it will be called?