1

I have a question is that how I can set the class property's default value and all available values in once. For example:

class MyClass{
  isActive = -1; //Set default value
}

class MyClass{
  isActive: -1 | 0 | 1; //Set all available value
}

And I want to do sth like this:
class MyClass{
  //isActive = -1 && isActive: -1 | 0 | 1
}
1
  • Set all available value is setting a type Commented Mar 11, 2020 at 5:38

1 Answer 1

2

You can use the syntax:

class MyClass {
    isActive: -1 | 0 | 1 = -1;
}

Just like it would be with a standalone variable name.

let isActive: -1 | 0 | 1 = -1;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.