Ask Your Question
0

How can arithmetic operations be applied to a type definition that is conditional?

asked 2023-07-15 19:45:04 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-07-15 20:06:02 +0000

ladyg gravatar image

Arithmetic operations cannot be applied to a type definition that is conditional because the type is not known until runtime. Conditional types are determined based on some conditions that are evaluated at runtime, and the type may change dynamically depending on the outcome of the evaluation. Arithmetic operations require a fixed type or a type that can be explicitly inferred at compile time, which cannot be guaranteed with conditional types.

However, arithmetic operations can be applied to values of a conditional type once they are resolved at runtime. For example, if a function returns a conditional type, the return value can be assigned to a variable of the appropriate type, and arithmetic operations can then be applied to the value.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-15 19:45:04 +0000

Seen: 14 times

Last updated: Jul 15 '23