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

Cannot assign null values #428

Open
michaelbukachi opened this issue Oct 12, 2020 · 0 comments
Open

Cannot assign null values #428

michaelbukachi opened this issue Oct 12, 2020 · 0 comments

Comments

@michaelbukachi
Copy link

Whenever I try to assign null values to expressions the following error is throw:

TypeError: Cannot read property 'toString' of undefined
    at generateRegExp (/Projects/Web/escodegen/node_modules/escodegen/escodegen.js:333:22)
    at generateExpression (/Projects/Web/escodegen/node_modules/escodegen/escodegen.js:1417:22)
    at generateStatement (/Projects/Web/escodegen/node_modules/escodegen/escodegen.js:1675:21)
    at Object.generate (/Projects/Web/escodegen/node_modules/escodegen/escodegen.js:2108:22)
    at Object.<anonymous> (/Projects/Web/escodegen/sample.js:2:26)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

Here's the sample code I'm using:

escodegen = require('escodegen')
const result = escodegen.generate({
    'type': 'VariableDeclarator',
    'id': {'type': 'Identifier', 'name': 'foo'},
    'init': {'type': 'Literal', 'raw': 'null'}});
console.log(result)

which is supposed to output:

const foo = null;

It seems a PR was opened in 2018 but was never merged (#380)
I'm going to open a new one based of the latest commit.

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