docs: update type terminology from Int/Float/String/Bool to Number/Decimal/Text/Boolean
This commit is contained in:
@@ -79,8 +79,8 @@ template Villager {
|
||||
```
|
||||
|
||||
**Range syntax:**
|
||||
- Integer ranges: `min..max` (inclusive)
|
||||
- Float ranges: `min..max` (inclusive)
|
||||
- Number ranges: `min..max` (inclusive)
|
||||
- Decimal ranges: `min..max` (inclusive)
|
||||
- Both bounds must be same type
|
||||
- min ≤ max required
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ Expressions are logical statements that evaluate to `true` or `false`. They comb
|
||||
| <quantifier>
|
||||
| "(" <expression> ")"
|
||||
|
||||
<literal> ::= <int> | <float> | <string> | <bool>
|
||||
<literal> ::= <number> | <decimal> | <text> | <boolean>
|
||||
|
||||
<identifier> ::= <simple-name>
|
||||
| <qualified-path>
|
||||
@@ -117,7 +117,7 @@ status == active
|
||||
|
||||
**Type compatibility:**
|
||||
- Both operands must be the same type
|
||||
- Works with: int, float, string, bool, enum values
|
||||
- Works with: number, decimal, text, boolean, enum values
|
||||
|
||||
### Inequality: `!=`
|
||||
|
||||
@@ -139,7 +139,7 @@ age < 18
|
||||
distance < 10.0
|
||||
```
|
||||
|
||||
**Valid types:** int, float
|
||||
**Valid types:** number, decimal
|
||||
|
||||
### Less Than or Equal: `<=`
|
||||
|
||||
@@ -459,15 +459,15 @@ Comparisons require compatible types:
|
||||
|
||||
| Operator | Left Type | Right Type | Valid? |
|
||||
|----------|-----------|------------|--------|
|
||||
| `==`, `!=` | int | int | ✓ |
|
||||
| `==`, `!=` | float | float | ✓ |
|
||||
| `==`, `!=` | string | string | ✓ |
|
||||
| `==`, `!=` | bool | bool | ✓ |
|
||||
| `==`, `!=` | number | number | ✓ |
|
||||
| `==`, `!=` | decimal | decimal | ✓ |
|
||||
| `==`, `!=` | text | text | ✓ |
|
||||
| `==`, `!=` | boolean | boolean | ✓ |
|
||||
| `==`, `!=` | enum | same enum | ✓ |
|
||||
| `==`, `!=` | int | float | ✗ |
|
||||
| `<`, `<=`, `>`, `>=` | int | int | ✓ |
|
||||
| `<`, `<=`, `>`, `>=` | float | float | ✓ |
|
||||
| `<`, `<=`, `>`, `>=` | string | string | ✗ |
|
||||
| `==`, `!=` | number | decimal | ✗ |
|
||||
| `<`, `<=`, `>`, `>=` | number | number | ✓ |
|
||||
| `<`, `<=`, `>`, `>=` | decimal | decimal | ✓ |
|
||||
| `<`, `<=`, `>`, `>=` | text | text | ✗ |
|
||||
|
||||
### Implicit Coercion
|
||||
|
||||
@@ -475,8 +475,8 @@ Comparisons require compatible types:
|
||||
|
||||
**Error:**
|
||||
```storybook
|
||||
count == "5" // Error: int vs string
|
||||
health < true // Error: int vs bool
|
||||
count == "5" // Error: number vs text
|
||||
health < true // Error: number vs boolean
|
||||
```
|
||||
|
||||
**Correct:**
|
||||
|
||||
@@ -8,10 +8,10 @@ Storybook supports 12 value types:
|
||||
|
||||
| Type | Example | Use Case |
|
||||
|------|---------|----------|
|
||||
| **Int** | `42`, `-7` | Quantities, IDs, counts |
|
||||
| **Float** | `3.14`, `-0.5` | Measurements, probabilities |
|
||||
| **String** | `"Hello"`, `"Martha"` | Text, names, descriptions |
|
||||
| **Bool** | `true`, `false` | Flags, switches |
|
||||
| **Number** | `42`, `-7` | Quantities, IDs, counts |
|
||||
| **Decimal** | `3.14`, `-0.5` | Measurements, probabilities |
|
||||
| **Text** | `"Hello"`, `"Martha"` | Text, names, descriptions |
|
||||
| **Boolean** | `true`, `false` | Flags, switches |
|
||||
| **Time** | `14:30`, `09:15:30` | Clock times, schedule blocks |
|
||||
| **Duration** | `2h30m`, `45s` | Time intervals |
|
||||
| **Range** | `20..40`, `0.5..1.0` | Template variation bounds |
|
||||
@@ -638,8 +638,8 @@ Storybook has **no implicit type coercion**. All type conversions must be explic
|
||||
**Not allowed:**
|
||||
```storybook
|
||||
character Wrong {
|
||||
count: "42" // Error: expected int, got string
|
||||
flag: 1 // Error: expected bool, got int
|
||||
count: "42" // Error: expected number, got text
|
||||
flag: 1 // Error: expected boolean, got number
|
||||
}
|
||||
```
|
||||
|
||||
@@ -680,10 +680,10 @@ Storybook **does not have `null`**. For optional values, use:
|
||||
|
||||
| Type | Mutable? | Comparable? | Valid in Templates? | Notes |
|
||||
|------|----------|-------------|---------------------|-------|
|
||||
| Int | No | Yes | Yes | 64-bit signed |
|
||||
| Float | No | Yes | Yes | 64-bit IEEE 754 |
|
||||
| String | No | Yes | Yes | UTF-8 |
|
||||
| Bool | No | Yes | Yes | true/false |
|
||||
| Number | No | Yes | Yes | 64-bit signed |
|
||||
| Decimal | No | Yes | Yes | 64-bit IEEE 754 |
|
||||
| Text | No | Yes | Yes | UTF-8 |
|
||||
| Boolean | No | Yes | Yes | true/false |
|
||||
| Time | No | Yes | No | HH:MM or HH:MM:SS |
|
||||
| Duration | No | Yes | No | Compounds (2h30m) |
|
||||
| Range | No | No | Yes (only) | Template variation |
|
||||
|
||||
Reference in New Issue
Block a user