Skip to content

Top level [...$vararg] in bundled file not resolving to command line arguments #1048

@7coil

Description

@7coil

I'm trying to grab the command line arguments using [...$vararg], which gets resolved to {...} in Lua.
Unfortunately, using [...$vararg] in the top level of the Lua bundle file results in the {...} to be placed inside a function, and no longer resolve the command line arguments.

image

As a temporary fix, I instead created a new global variable at the top of the generated file with the contents of {...}, and using that variable to access the argv's.

I'm not an avid Lua user, but I might suggest somehow passing the command line arguments to (only?) the main module.

image

tsconfig.json

{
  "compilerOptions": {
    "target": "esnext",
    "lib": [
      "esnext"
    ],
    "moduleResolution": "node",
    "types": ["lua-types/5.1"],
    "strict": true,
    "outDir": "dist/"
  },
  "tstl": {
    "luaTarget": "5.1",
    "luaBundle": "output.lua",
    "luaBundleEntry": "src/index.ts"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions