Exclude enum/number compatibility rule from comparable relation by ahejlsberg · Pull Request #42472 · microsoft/TypeScript (original) (raw)
The only test changes related to this PR are some new errors in the RWC vscode project. All but one of them are flagging real issues. For example, code that declares something as a KeyCode[]
, but then compares element values to -1
, which doesn't match any declared KeyCode
member. So, the array declaration should really be (KeyCode | -1)[]
.
The one undesired new error is related to this enum declaration in vs/editor/common/modes.ts:
/**
- Open ended enum at runtime
- @internal */ export const enum LanguageId { Null = 0, PlainText = 1 }
The intent here is for LanguageId
to be a numeric (i.e. non-union) enum. This can be accomplished by changing one of the enum values to a computed expression:
export const enum LanguageId { Null = +0, PlainText = 1 }
Subtle, but actually an intended and documented behavior.