GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Visitor plugin not called for decorator node · Issue #1626 · TypeScriptToLua/TypeScriptToLua

Visitor plugin not called for decorator node #1626

New issue
Copy link
New issue
Copy link
Open
Open
Visitor plugin not called for decorator node#1626
Copy link

Description

@takegine
takegine
opened on Mar 26, 2025
Issue body actions
// 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

Activity

  1. Perryvw
    changed the title [-]plugin error with[/-] [+]Visitor plugin not called for decorator node[/+] on Mar 26, 2025
  2. Perryvw commented on Mar 26, 2025

    @Perryvw
    Perryvw
    on Mar 26, 2025
    Member
    More actions

    Current tstl implementation does not directly visit decorators, instead, decorators are handled as part of the class visitor. I will have a think about if we want to make some kind of change here, but for now you can get the decorators like this:

    const plugin: tstl.Plugin = {
      visitors: {
        [ts.SyntaxKind.ClassDeclaration]: (node, context) => {
          if (ts.canHaveDecorators(node)) {
            const decorators = ts.getDecorators(node) ?? [];
              for (const decorator of decorators) {
                console.log("Found decorator:", decorator.getText());
              }
          }
          return context.superTransformStatements(node);
        }
      },
    };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.