#Type 'false' cannot be used as an index type?
5 messages · Page 1 of 1 (latest)
Preview:```ts
const items = {
false: "false",
yes: "y",
no: "n",
}
console.log(items[false])```
You can choose specific lines to embed by selecting them before copying the link.
{ false: "false" } is equivalent to { "false": "false" }; object keys are only strings, numbers, or symbols
if that works at runtime, then it works because of a conversion, which TS generally disallows even though "it works at runtime", as such code is usually not intentional
Ah right! Thanks