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

Incompatible with latest release of Peggy.js #78

Closed
carlossantillana opened this issue Jun 1, 2022 · 3 comments
Closed

Incompatible with latest release of Peggy.js #78

carlossantillana opened this issue Jun 1, 2022 · 3 comments

Comments

@carlossantillana
Copy link

carlossantillana commented Jun 1, 2022

Peggy.js just released a breaking release which amongst other things changes how allowedStartRules are defined peggyjs/peggy#175
As a result, running node src/generate-parser.js with the ts-pegjs plugin now causes the error below to occur

/path-to-project/node_modules/ts-pegjs/src/passes/generate-ts.js:1076
        options.allowedStartRules.map(
                                  ^

TypeError: Cannot read properties of undefined (reading 'map')
    at generateToplevel (/path-to-project/node_modules/ts-pegjs/src/passes/generate-ts.js:1076:35)
    at generateTS (/path-to-project/node_modules/ts-pegjs/src/passes/generate-ts.js:1562:30)
    at /node_modules/peggy/lib/compiler/index.js:99:9
    at Array.forEach (<anonymous>)
    at /node_modules/peggy/lib/compiler/index.js:96:21
    at Array.forEach (<anonymous>)
    at Object.compile (/node_modules/peggy/lib/compiler/index.js:92:25)
    at Object.generate /node_modules/peggy/lib/peg.js:112:25)
    at /expression-parser/src/generate-parser.js:7:22
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)

minimal reproducible config

// generate-parser.js
var fs = require('fs');
var peggy = require('peggy');
var tspegjs = require('ts-pegjs');

fs.readFile('examples/arithmetics.pegjs', function (err, data) {
  if (err) throw err;
  var parser = peggy.generate(data.toString(), {
    output: 'source',
    cache: true,
    plugins: [tspegjs],
    tspegjs: {
      customHeader: '// @ts-nocheck',
    },
  });
  fs.writeFileSync('examples/arithmetics.ts', parser);
});

@pjmolina
Copy link
Contributor

pjmolina commented Jun 1, 2022

Thanks for reporting @carlossantillana
We will look for a fix.

@blitz-1306
Copy link

@pjmolina Hey there. Are there any updates on this issues? (:

@pjmolina
Copy link
Contributor

pjmolina commented Jul 4, 2022

  • Added support for peggy 2.0.1 with 6f9ff31
  • Published as ts-pegjs 2.0.1

Note that previous version of ts-pegjs was supporting peggy ^1.2.0 only.

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

3 participants