@tilua/parser 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -3
- package/dist/index.cjs +363 -61
- package/dist/index.d.cts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +363 -61
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -341,9 +341,11 @@ name: T | nil -- must be written, but may be nil
|
|
|
341
341
|
Omitting an argument requires `?` (or a default), as in TypeScript — a
|
|
342
342
|
parameter typed `T | nil` still has to be passed something.
|
|
343
343
|
|
|
344
|
-
**Optional chaining** — `a?.b` and `a?:m(x)` are nil when
|
|
345
|
-
nothing further along the chain runs, arguments
|
|
346
|
-
is a `string | nil
|
|
344
|
+
**Optional chaining** — `a?.b`, `a?.[k]`, `a?.(x)` and `a?:m(x)` are nil when
|
|
345
|
+
`a` is, and then nothing further along the chain runs, arguments and the key
|
|
346
|
+
included: `folder?:FindFirstChild("A")?.Name` is a `string | nil`, and
|
|
347
|
+
`maps?.[key]?.label` reads the key only when `maps` is there. The `?` must
|
|
348
|
+
touch the `.` or `:`; `c ? a : b` stays a
|
|
347
349
|
ternary. Parentheses end a chain. A chain cannot be assigned to (`a?.b = 1` is
|
|
348
350
|
an error). A chain that got through narrows what it tested: inside
|
|
349
351
|
`if (part?.Parent)`, and `if (part?.Name == "Door")`, `part` is not nil.
|
|
@@ -743,6 +745,17 @@ non-nil part.
|
|
|
743
745
|
|
|
744
746
|
Only `nil` and `false` are falsy — `0` and `""` are truthy, unlike JavaScript.
|
|
745
747
|
|
|
748
|
+
**What Luau raises on is said first.** An operator no metamethod answers takes
|
|
749
|
+
numbers — `..` a string or a number, `#` a string or a table — so `n * 2` with
|
|
750
|
+
`n` a `number | nil` is an error where it is written rather than where it runs.
|
|
751
|
+
A comparison two types can never settle (`s == "c"` with `s` a `"a" | "b"`) is
|
|
752
|
+
one too; a test against `nil` never is, since a map's value and an array's
|
|
753
|
+
element are read as what they hold. A name holds nothing until its line has
|
|
754
|
+
run, a list is indexed by position (`xs["a"]` is not a read), `readonly T[]`
|
|
755
|
+
rules out writing to the list as well as passing it where a `number[]` is
|
|
756
|
+
wanted, a key written twice in one table is reported, and a parameter with no
|
|
757
|
+
type says so — it is `any`, and `any` turns off every check made of it.
|
|
758
|
+
|
|
746
759
|
**Types** — unions, intersections, tuples `[A, B]` (with a rest, `[A,
|
|
747
760
|
...B[]]`), `keyof`, `T[K]`, conditional types with
|
|
748
761
|
`infer`, mapped types with `as` remapping, template literal types
|