⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.1.6#code/MYewdgzgLgBApmArgWxgFTtAok1BvAKBmJgEEYBeGARgBoiSAhSmAWmoIF8CDRIQANnAB0AkAHMAFA2JQAngAc4IAGYwAylABOASzBSM2XMNIBKeiRjylq9Jig4UJ4VBCbd+yaYLfe4CIIiYlIyVorKau56BvaOyMKM5qHWEXZGTowubtrRXj5AA
💻 Code
constenumTestEnum{A=1,B=-1}// "string", "string" console.log(typeofString(TestEnum.A),typeofTestEnum.A.toString())// "string", "number" console.log(typeofString(TestEnum.B),typeofTestEnum.B.toString())🙁 Actual behavior
Constant enums which use negative numbers will return type of number when .toString() is called.
🙂 Expected behavior
A string type should be returned
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.1.6#code/MYewdgzgLgBApmArgWxgFTtAok1BvAKBmJgEEYBeGARgBoiSAhSmAWmoIF8CDRIQANnAB0AkAHMAFA2JQAngAc4IAGYwAylABOASzBSM2XMNIBKeiRjylq9Jig4UJ4VBCbd+yaYLfe4CIIiYlIyVorKau56BvaOyMKM5qHWEXZGTowubtrRXj5AA
💻 Code
🙁 Actual behavior
Constant enums which use negative numbers will return type of
numberwhen.toString()is called.🙂 Expected behavior
A
stringtype should be returned