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

Acorn-typescript plugin error #3220

Closed
bpstrngr opened this issue Oct 2, 2022 · 1 comment
Closed

Acorn-typescript plugin error #3220

bpstrngr opened this issue Oct 2, 2022 · 1 comment
Assignees

Comments

@bpstrngr
Copy link

bpstrngr commented Oct 2, 2022

I'm trying to use your acorn-typescript AST helper plugin as it seems the most advanced vanillajs solution (microsoft/typescript is written in ts itself so needs itself to build itself, as well as @babel/parser, which is just a fork of acorn anyway, while the former seems to have a too complicated structure for my comprehension, but these aren't to be discussed here). When I extend acorn with it though, it's throwing an error at the first typescript syntax:

import {Parser,parse} from "./acorn/acorn/src/index.js";
import parseTypescript from "./patternfly-org/packages/ast-helpers)/acorn-typescript.js";
function compile(source,dialect){
  if(dialect=="typescript")
  Parser.extend(parseTypescript);
  parse(source,{sourceType:"module"});
}
compile(source,"typescript");
SyntaxError: Unexpected token (4:12) {
                pos: 131,
                loc: Position { line: 4, column: 12 },                                                               
                raisedAt: 132
}

The code at that location being:

  import { version as rollupVersion } from 'package.json';
  import Bundle from '../Bundle';
  import Graph from '../Graph';
> import type { PluginDriver } from '../utils/PluginDriver';
  [...]

Am I using it wrong or is this an unsupported typescript syntax?
Would you have recommendations on where to start fixing this?
Thanks!

@evwilkin
Copy link
Member

@bpstrngr thanks for your questions. This acorn-typescript package is something we pulled in for our own build system, but is not code that we created or are able to support for the community - the original code lives in this repo, and you have more luck troubleshooting with the author:

You may also look at not using the import type { PluginDriver } syntax and just use import { PluginDriver }, more info here:

@evwilkin evwilkin moved this to Done in PatternFly Issues Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants