A repo demonstrating using acorn on TypeScript files.
- Clone the repo
- Run
npm ci
Two scripts are available:
npm run ts
- Runstsc
against the main filenpm run acorn
- Loads the contents of the main file into acorn to parse / walk it
Current issue seems to be that acorn-typescript seems to fail
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
walk.simple(node, {}, {
...walk.base,
TSInterfaceDeclaration: () => { }
});
Which also seems to be the case with the acorn-jsx plugin, so does that mean there is an entire list of these TS visitors that we need to configure? ๐ค