A
A
Alex102142022-01-24 16:50:39
typescript
Alex10214, 2022-01-24 16:50:39

How to set a class type to a variable?

hello, I am rewriting back from java to nodeJS
In the java code, I often encounter such variables:
Trade_account trade_account;

after digging in the code, I realized that the 'trade_account' variable was assigned the class type 'Trade_account'.
And hence the actual question, is it possible to specify the type of a class in typescript variables?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2022-01-24
@Alex10214

Yes.

let trade_account: Trade_account | null | undefined; // явно указываем, что тип переменной - это undefined или Trade_account или null

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question