azerothcore / azerothcore/eluna-ts

Global functions get transpiled with a nil first argument

Open
#1 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
38
Forks
4
PR merge metrics
No merged PRs in 30d

Description

It seems that some functions that are available from the global scope are incorrectly transpiled to Lua.
For example:
```typescript
const map = GetMapById(1);
print(map.GetName());
```
transpiles to
```lua
local map = GetMapById(nil, 1)
print(
map:GetName()
)
```
notice the `nil` before the `1`, which causes an error: `bad argument #1 to 'GetMapById' (number expected, got nil)`


Same behavior with
```typescript
const query = CharDBQuery("...");
```
which transpiles to
```lua
local query = CharDBQuery(nil, "...")
```
and therefore gives the error `bad argument #1 to 'CharDBQuery' (string expected, got nil)`


I'm using the following versions:
* `@azerothcore/eluna-ts-lib`: `^1.0.13`
* `typescript`: `4.2.4`
* `typescript-to-lua`: `^0.39.3`
* Node v14.16.0

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with the GetMapById and CharDBQuery examples, then trace how global function calls are transpiled. Confirm that the generated Lua no longer inserts a nil first argument and that both examples pass their actual arguments correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.