TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
- operator in TypeScript operates in two distinct compilation contexts: at the type level to declare negative literal types and remove mapping modifiers, and at the value level as a strictly-typed arithmetic operator for binary subtraction and unary negation.
Type-Level Negative Literals
In TypeScript’s type system, the- operator acts as a prefix to define negative numeric and bigint literal types. It modifies a positive literal type into its negative counterpart.
Syntax:
Type-Level Mapping Modifier
Within mapped types, the- operator is used as a prefix to subtract (remove) specific modifiers from property signatures. It can be applied to the readonly modifier to remove immutability, or to the ? modifier to remove optionality.
Syntax:
-readonly: Strips thereadonlyflag, making the resulting property mutable.-?: Strips the?flag, making the resulting property required.
Value-Level Binary Subtraction
At runtime, the- operator performs binary subtraction. Unlike JavaScript, which allows implicit type coercion (e.g., "5" - 2), TypeScript’s static type checker enforces strict operand constraints. Both the left and right operands must resolve to number, bigint, any, or an enum type.
Syntax:
Value-Level Unary Negation
When used as a unary prefix, the- operator negates the numeric value of its operand. TypeScript enforces strict type constraints, rejecting types that would rely on JavaScript’s implicit runtime coercion to NaN or numbers.
Syntax:
Master TypeScript with Deep Grasping Methodology!Learn More





