Answer the question
In order to leave comments, you need to log in
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
Yes.
let trade_account: Trade_account | null | undefined; // явно указываем, что тип переменной - это undefined или Trade_account или null
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question