No sé cómo escribir el tipo root
El siguiente código:
class BST { // root is `BST.Node`'s instance root: ???; constructor (key: number, value: any) { this.root = new BST.Node(key, value) } static Node = class { key: number value: any constructor (key: number, value: any) { this.key = key this.value = value } } } const t = new BST(1, 'data') console.log(t.root instanceof BST.Node) // expected: truePuedes usar Tipo de InstanceType :
class BST { // root is `BST.Node`'s instance root: InstanceType<typeof BST.Node>; constructor (key: number, value: any) { this.root = new BST.Node(key, value) } static Node = class { key: number value: any constructor (key: number, value: any) { this.key = key this.value = value } } } const t = new BST(1, 'data') console.log(t.root instanceof BST.Node) // expected: true