Skip to content

Visitor plugin not called for decorator node #1626

Description

@takegine
// plugin.ts
import * as ts from "typescript";
import * as tstl from "typescript-to-lua";

console.log("Plugin is being loaded!");
const plugin: tstl.Plugin = {
    visitors: {
        [ts.SyntaxKind.Decorator]: (node, context) : tstl.Node[] => {
            console.log("Found decorator:", node.getText()); // Didn't see it in the console
            return context.superTransformNode(node);
        }
    },
};

export default plugin;
//tsconfig.json

    "tstl":{
        "luaTarget": "JIT",
        "sourceMapTraceback":true,
        
        "luaPlugins": [
            { "name": "./plugin.ts" }
        ]
    },
    "compilerOptions": {
        
        "experimentalDecorators": true,
    }
const declareModifier = (
    type: LuaModifierType | LuaModifierMotionType,
    name?: string,
) => (modifier: new () => Partial<CDOTA_Modifier_Lua>) => {};


@declareModifier(LuaModifierType.LUA_MODIFIER_MOTION_NONE)
class modifier_npc_recycle implements Partial<CDOTA_Modifier_Lua> {

    static OnCreated(params: object): void {
        print(111)
    }
    static CheckState(): Partial<Record<modifierstate, boolean>> {
        return {
            // [modifierstate.MODIFIER_STATE_INVISIBLE]: true,
            // [modifierstate.MODIFIER_STATE_NO_HEALTH_BAR]: true,
            // [modifierstate.MODIFIER_STATE_NO_UNIT_COLLISION]: true,
            // [modifierstate.MODIFIER_STATE_INVULNERABLE]: true,
        };
    }
}

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions