-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 2.8.0-dev.20180228
Search Terms: undefined strictNullChecks bitwise and or
(ref: #22088 (comment))
Code
const enum Flags { A = 2 ** 1, B = 2 ** 2 }
function f(flags?: Flags) {
if (flags & Flags.B) {
}
}Expected behavior:
No error. & and | work well on undefined values: undefined | 2 is 2, undefined & 2 is 0. Contrast with undefined + 2 which is NaN.
Actual behavior:
src/a.ts(3,9): error TS2532: Object is possibly 'undefined'.Metadata
Metadata
Assignees
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptAn idea for TypeScript