I want to define an array with a constant value
e.g. const arr = ["a", "b"];. However, the compiler will think it's string[]. Is there is a way to make it a constant type as is so the type of arr should be ["a", "b"]. The only way I found was to do like: const arr: ["a", "b"] = ["a", "b"];. but it's like code duplication.
Add a comment
|