@tilua/parser 3.0.1 → 4.0.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 +29 -10
- package/dist/index.cjs +515 -93
- package/dist/index.d.cts +84 -5
- package/dist/index.d.ts +84 -5
- package/dist/index.js +504 -92
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -124,14 +124,31 @@ Every problem comes back as `{ file, message, line, column }`, pointing into
|
|
|
124
124
|
the config (or sourcemap) it is about. `host` reads files — pass your own to
|
|
125
125
|
read unsaved editor buffers or to record what was read.
|
|
126
126
|
|
|
127
|
-
`
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
`typeof v` is the language's own, an operator like `not` and `#`: it needs no
|
|
128
|
+
library, and Lua's `type()` and Luau's `typeof()` functions are declared by
|
|
129
|
+
none. It answers Luau's names — `"nil"`, `"boolean"`, `"number"`, `"string"`,
|
|
130
|
+
`"function"`, `"thread"`, `"buffer"`, `"userdata"` — except for a table, which
|
|
131
|
+
is an `"array"` or an `"object"`. `typeof v == "array"` narrows `v`, and
|
|
132
|
+
`== "table"` is an error: it is never the answer. There is no `typeof(v)`
|
|
133
|
+
function: written that way it is an error, and a parenthesised operand stands
|
|
134
|
+
apart from the operator — `typeof (a or b)`.
|
|
135
|
+
|
|
136
|
+
What a runtime's own values answer is a library's to say, in one alias:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
type TypeofNames = { Vector3: Vector3, Instance: Instance }
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Each property is the name `typeof` gives a value of the property's type; a
|
|
143
|
+
value several fit (a `Part` is an `Instance`) is the first one's.
|
|
144
|
+
`TypeAnalysis.typeofTables` lists each `typeof v` whose `v` is, by its type,
|
|
145
|
+
an array or an object wherever it is a table — what a compiler need not find
|
|
146
|
+
out as the program runs.
|
|
130
147
|
|
|
131
148
|
Libraries stack: a name declared again *adds* to what an earlier library gave
|
|
132
149
|
it — overloads of a function accumulate, and the members of a declared table
|
|
133
|
-
merge. That is how `@tilua-types/roblox` extends Lua's `table`
|
|
134
|
-
restating
|
|
150
|
+
merge. That is how `@tilua-types/roblox` extends Lua's `table` without
|
|
151
|
+
restating it.
|
|
135
152
|
|
|
136
153
|
## The language, in brief
|
|
137
154
|
|
|
@@ -340,7 +357,8 @@ such as `print(x)`, and `globalValue` for a global read as a value, such as
|
|
|
340
357
|
`local p = print`. A local with the same name belongs to the author, and no
|
|
341
358
|
hook is asked about it. A runtime can read `__LINES__`, the bundle's line map
|
|
342
359
|
(`nil` outside a bundle), to turn a line Luau reports back into a place in the
|
|
343
|
-
project.
|
|
360
|
+
project. One that answers with a new array wraps it in `__ARRAY__(...)`, which
|
|
361
|
+
writes it down as an array for `typeof`. `console:log`, `print` and `error` in `@tilua-types/lua` are built on
|
|
344
362
|
these hooks.
|
|
345
363
|
|
|
346
364
|
**A `(` that starts a line** continues the statement above it, as in Lua and
|
|
@@ -383,8 +401,8 @@ declare class Part extends BasePart { Shape: EnumItem }
|
|
|
383
401
|
A `Part` is a `BasePart` and an `Instance` because it extends them. A
|
|
384
402
|
`ReplicatedStorage` is not a `Part`, and no table literal is an `Instance`,
|
|
385
403
|
however alike their members. A class still fits a shape that names members it
|
|
386
|
-
has (`{ Name: string }`). It is not a table, though, so `typeof
|
|
387
|
-
|
|
404
|
+
has (`{ Name: string }`). It is not a table, though, so `typeof part` is
|
|
405
|
+
`"Instance"`, as the library's `TypeofNames` says, not `"object"`. Members are inherited, and a subclass
|
|
388
406
|
may narrow one (`Parent: SomeFolder`).
|
|
389
407
|
|
|
390
408
|
**`class ... { }`** — a class written in code, rather than declared in a
|
|
@@ -804,8 +822,9 @@ three operators: only a call after the `>` makes it type arguments.
|
|
|
804
822
|
|
|
805
823
|
`typeof x` in a type is TypeScript's type query — the type of a value
|
|
806
824
|
(`typeof config`, `typeof config.volume`, `ReturnType<typeof f>`). Luau's
|
|
807
|
-
`typeof(expr)` spelling
|
|
808
|
-
`typeof
|
|
825
|
+
`typeof(expr)` spelling is an error here as well. It is compile-time only, unrelated to the
|
|
826
|
+
`typeof v` operator in an expression, which answers a string as the program
|
|
827
|
+
runs.
|
|
809
828
|
|
|
810
829
|
**Modules** — `import` / `export`, export lists, re-exports and `export *`.
|
|
811
830
|
|