Skip to content

fixing various bugs + adding another example #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/advanced/language-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ foo, four = myFunc(nil)

## $range Iterator Function

Typescript's numeric for loops are less restrictive than Lua's, so they are transpiled into while loops instead. To create a Lua-style numeric for loop, you can use the `$range` language extension in a for...of loop.
TypeScript's numeric for loops are less restrictive than Lua's, so they are transpiled into while loops instead. To create a Lua-style numeric for loop, you can use the `$range` language extension in a for...of loop.

Example:

Expand All @@ -86,7 +86,7 @@ for i = 5, 1, -1 do end

## LuaIterable Type

Iterators in Lua work quite differently than in Typescript/Javscript, so a special type is needed to use them.
Iterators in Lua work quite differently than in TypeScript/JavaScript, so a special type is needed to use them.

For example, to declare and use a Lua function that returns an iterator for a set of strings, you can do this:

Expand Down Expand Up @@ -150,7 +150,7 @@ See the [Lua Reference Manual](https://www.lua.org/manual/5.3/manual.html#3.3.5)

## Operator Map Types

Lua supports overloading operators on types using [metatable methods](https://www.lua.org/manual/5.4/manual.html#2.4) such as `__add`. But, Javascript and Typescript do not support this. In order to use overloaded operators on types that support them, you can declare special mapping functions in TS that will translate to those operators in Lua.
Lua supports overloading operators on types using [metatable methods](https://www.lua.org/manual/5.4/manual.html#2.4) such as `__add`. But, JavaScript and TypeScript do not support this. In order to use overloaded operators on types that support them, you can declare special mapping functions in TS that will translate to those operators in Lua.

A common example of an overloaded operator is addition of a mathematical vector type:

Expand Down Expand Up @@ -230,7 +230,7 @@ You can also map functions to table accessors (`__index` and `__newindex`). See

## Lua Table Types

The `LuaTable` type is provided to allow direct creation and manipulation of Lua tables. This is useful if you want to use a table that uses types other than string for its keys, as that is not supported by Typescript. Calls to lua method tables are translated to simple lua:
The `LuaTable` type is provided to allow direct creation and manipulation of Lua tables. This is useful if you want to use a table that uses types other than string for its keys, as that is not supported by TypeScript. Calls to lua method tables are translated to simple lua:

- `table.get(key)` Get a value by key -> `table[key]`
- `table.set(key, value)` Set a value for key -> `table[key] = value`
Expand Down Expand Up @@ -370,7 +370,7 @@ There are more LuaTable functions other than `LuaTableGet` and `LuaTableSet` tha

## $vararg Constant

Lua allows use of the ellipsis operator (`...`) to access command line arguments passed when executing a script file. To access this from Typescript, you can use the `$vararg` constant in a spread expression.
Lua allows use of the ellipsis operator (`...`) to access command line arguments passed when executing a script file. To access this from TypeScript, you can use the `$vararg` constant in a spread expression.

Example:

Expand Down
1 change: 1 addition & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ The real power of this transpiler is usage together with good declarations for t
- [World of Warcraft - Addon Development](https://github.com/wartoshika/wow-declarations)
- [World of Warcraft Classic - Addon Development](https://github.com/wartoshika/wow-classic-declarations)
- [Factorio Type Kit](https://cdaringe.github.io/factorio-type-kit/)
- [The Binding of Isaac: Rebirth](https://isaacscript.github.io)
6 changes: 3 additions & 3 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ module.exports = {
},
footer: {
logo: {
alt: "TypescriptToLua Logo",
alt: "TypeScriptToLua Logo",
src: "images/logo.png",
href: "https://github.com/TypescriptToLua",
href: "https://github.com/TypeScriptToLua",
},
links: [
{
Expand Down Expand Up @@ -64,7 +64,7 @@ module.exports = {
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} TypescriptToLua Contributors`,
copyright: `Copyright © ${new Date().getFullYear()} TypeScriptToLua Contributors`,
},
prism: {
additionalLanguages: ["lua"],
Expand Down