This seems to be a confusion about what Test[0] is. Numeric enum members in TypeScript get a reverse mapping, where indexing into the enum object with an enum value gives you back the corresponding enum key.
So in
enum Test {
a = 0,
b = 1
}
you have Test.a === 0 and therefore Test[0] === "a". And since Test.b === 1, then Test[1] === "b". By comparing Test.a to Test[0], you are comparing a number to a string, and is indeed considered a TypeScript error to make such a comparison.
So you shouldn't write
console.log(Test.a === Test[0]); // error, different types. Outputs false
But instead possibly one of these:
console.log("a" === Test[0]); // okay, Outputs true
console.log(Test.a === 0); // okay, Outputs true
Playground link to code
Test[0]is using the reverse mapping to get"a". Why are you trying to compare them like that? Either you wantconsole.log(Test.a === 0)orconsole.log("a" === Test[0]), but what you're doing is checking a key against a value. Does that make sense and should I write up an answer? Or am I missing something about your question?