This message was deleted.
# typescript
s
This message was deleted.
c
It's manual. You have to declare an interface in TS and assign the result to a variable of that interface type. Then you get the full type. It is not optimal but it is the (only?) way right now.
r
in TS you can also cast unknown to an interface (as already mentioned), or
any
to achieve this
Copy code
> const x: unknown = { a: { b: { x: "foo" }}};
undefined
> console.log((x as { a: {b: {x: string; }}}).a.b.x)
foo
> console.log((x as any).a.b.x)
foo
creating an interface to represent your config is considered idiomatic typescript. Here interface A represents the structure of the “a” config key:
Copy code
interface A {
   b: {
      x: string;
   }
}

const myA = config.requireObject<A>("a");  // generic cast
const x = myA.b.x;