Skip to content

Custom JSX factory incorrectly produces nil self parameter #1262

@andrei-markeev

Description

@andrei-markeev

Hi,

I am trying to compile JSX with custom jsxFactory pointing to createElement function.
TypeScriptToLua generates extra nil parameter in the output:

test_jsx.ts:

function createElement(tag: string | Function, props: { [key: string]: string | boolean }, ...children: any[]) {
    return "whatever, just testing";
}

function testJsx() {
    return <div></div>
}

test_jsx.lua:

--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
function createElement()
    return "whatever"
end
function testJsx()
    return createElement(nil, "div", nil)
end

I would expect that it would generate this:

    return createElement("div", nil);

I have noImplicitSelf in tsconfig, and I also tried setting /** @noSelf */ attribute, but both of these are ignored.

tsconfig.json:

{
    "compilerOptions": {
        "target": "esnext",
        "lib": [
            "esnext"
        ],
        "jsx": "react",
        "jsxFactory": "createElement",
        "moduleResolution": "node",
        "types": ["lua-types/jit"],
        "strict": true,
        "outDir": "build"
    },
    "tstl": {
        "luaTarget": "JIT",
        "noImplicitSelf": true
    }
}

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