I
I
IDONTSUDO2020-05-27 02:09:09
Unit testing
IDONTSUDO, 2020-05-27 02:09:09

TypeScript typing runtime?

static CreateChapter(){
      rpc.callServer('createCharacter',auth.name).then((response) =>{
          if(response){
              // ANY code
          }
      })
  }


I have such code. Where any is some kind of logic that goes on the basis of the fact that something is contained in the response object. There I write a check for the existence of any properties. I know that TS can't runtime typing. But the question is, can I somehow type my server responses using the interfaces that were described before?

That is, I would like to see such logic approximately.

if(keyof CreateCharacter)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IDONTSUDO, 2020-05-27
@IDONTSUDO

https://github.com/marchaos/jest-mock-extended found such a thing

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question