Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

Broken with export const #6

Open
ckknight opened this issue Feb 9, 2016 · 5 comments
Open

Broken with export const #6

ckknight opened this issue Feb 9, 2016 · 5 comments

Comments

@ckknight
Copy link

ckknight commented Feb 9, 2016

With esformatter 0.9.0 and esformatter-var-each 2.1.0:

Input:

export const WAT = {};

Output:
Cannot read property 'indexOf' of undefined

@twolfson
Copy link
Owner

twolfson commented Feb 9, 2016

Can you provide the rest of the stack trace?

@ckknight
Copy link
Author

No, I cannot.

$ $(npm bin)/esformatter tmp.js 
Cannot read property 'indexOf' of undefined

@twolfson
Copy link
Owner

Alright, we will take a look at reproducing this issue by the end of next weekend.

@twolfson
Copy link
Owner

I have reproduced the error on dev/export.support but I believe it looks like the code won't be easily resolvable.

We are going to want to support a syntax like:

export const a = 'hello', b = 'world';

which we would convert to:

export const a = 'hello';
export const b = 'world';

The root cause of the problem is we currently assume that there is a single VariableDeclaration node (e.g. var, let, const). However, when we add an export there are 2 nodes that we need to clone to the head of each var (i.e. ExportNamedDeclaration and VariableDeclaration).

I'm going to mark this issue as "help wanted".

@millermedeiros
Copy link

millermedeiros/esformatter#450 is probably related to this

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

No branches or pull requests

3 participants