#Nested generic "cannot be used to index type"

2 messages · Page 1 of 1 (latest)

abstract sonnetBOT
#
bnason#0

Preview:```ts
const IExample = {
foo: {
bars: {
bar: {
baz: 1,
},
},
},
}

type F = <
name extends keyof typeof IExample,
val extends keyof typeof IExample[name]

() => typeof IExample[name][val]

const foo = <
name extends keyof typeof IExample,
val extends keyof typeof IExample[name]["bars"]

(
...```

unborn elk
#

However, this example does work. For some reason referencing the ['bars'] breaks it somehow that I don't understand.