Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatibility with acorn.walk (visitor types) #57

Open
thescientist13 opened this issue Jun 15, 2024 · 0 comments
Open

compatibility with acorn.walk (visitor types) #57

thescientist13 opened this issue Jun 15, 2024 · 0 comments

Comments

@thescientist13
Copy link

With the following bit of code, I ran into this issue when trying to walk this with acorn.walk

interface User {
  name: string;
}

export default class Greeting extends HTMLElement {
  connectedCallback() {
    const user: User = {
      name: this.getAttribute('name') || 'World'
    };

    this.innerHTML = `
      <h3>Hello ${user.name}!</h3>
    `;
  }
}
file:///Users/owenbuckley/Workspace/github/acorn-ts-example/node_modules/acorn-walk/dist/walk.mjs:23
    baseVisitor[type](node, st, c);
                     ^

TypeError: baseVisitor[type] is not a function
    at c (file:///Users/owenbuckley/Workspace/github/acorn-ts-example/node_modules/acorn-walk/dist/walk.mjs:23:22)
    at Module.simple (file:///Users/owenbuckley/Workspace/github/acorn-ts-example/node_modules/acorn-walk/dist/walk.mjs:25:5)
    at file:///Users/owenbuckley/Workspace/github/acorn-ts-example/acorn-ts.js:18:6
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

Unless acorn.walk is initialized with this option to explicitly support the usage of interface, which is similar to an observation I saw when using acorn-jsx plugin

walk.simple(node, {}, {
  ...walk.base,
  TSInterfaceDeclaration: () => { }
});

Is this expected? Is there some list of these visitor types available somewhere I should be using?

Here's a basic repro repo you can check out
https://github.com/thescientist13/acorn-ts-example

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant