N
N
neroslava2020-07-05 12:16:47
typescript
neroslava, 2020-07-05 12:16:47

How to implement this in typescript?

how to implement similar method call in typescript i get error
let p = new PacketWriter["writeVarInt"](0);

TS7053: Element implicitly has an 'any' type because expression of type '"writeVarInt"' can't be used to index type 'typeof PacketWriter'.
  Property 'writeVarInt' does not exist on type 'typeof PacketWriter'.

the method exists and is normally called like this, but I need to call my own class method for each argument and I want to do it without branching
let p = new PacketWriter.writeVarInt(0);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
neroslava, 2020-07-05
@neroslava

let p = new PacketWriter[method](0);
method must be constant

A
Alex, 2020-07-05
@Kozack

Similar

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question