I
I
iluxa18102019-04-05 13:23:57
typescript
iluxa1810, 2019-04-05 13:23:57

What is the order of class members in TypeScript?

Tell me, in what order is it customary to list the elements of a class in TypeScript?
By class element, I mean all sorts of fields, methods ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Brezhnev, 2019-04-05
@vanchelo

We adopted this order on projects

public-static-field
protected-static-field
private-static-field

public-instance-field
protected-instance-field
private-instance-field

constructor

public-static-method
protected-static-method
private-static-method

public-instance-method
protected-instance-method
private-instance-method

R
Robur, 2019-04-05
@Robur

One of the most important rules. All the same, intelligence and navigation in ide will be used.
The most general approach is the properties in a bunch and the constructor at the beginning, the statics are also somewhere nearby, everything else (no one will look for this with their hands anyway) later.
Something more strict - already unnecessary bureaucracy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question