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

Breaking: parse export default function () {} as a FunctionDeclaration with null id #512

Closed
hzoo opened this issue Feb 16, 2017 · 3 comments

Comments

@hzoo
Copy link

hzoo commented Feb 16, 2017

Ref estree/estree#98 (comment)
Previous discussion: #208

The consensus for ESTree is to make export default function () {} parse as a FunctionDeclaration with the id property with a value of null (matches current behavior of Esprima, Espree, Flow, Babylon) rather than FunctionExpression

Espree workaround is https://github.com/eslint/espree/blob/a3442b5949dd249e1a81ce4e014ca5e0f17f732c/espree.js#L197-L202

interface OptFunctionDeclaration <: FunctionDeclaration {
    id: Identifier | null;
}

interface OptClassDeclaration <: ClassDeclaration {
    id: Identifier | null;
}

interface ExportDefaultDeclaration <: ModuleDeclaration {
    type: "ExportDefaultDeclaration";
    declaration: OptFunctionDeclaration | OptClassDeclaration | VariableDeclaration | Expression;
}

screen shot 2017-02-15 at 7 16 06 pm

@marijnh
Copy link
Member

marijnh commented Feb 16, 2017

Does attached patch look good to you?

I guess we'll have to release it as a new major version. @RReverser Do you know of any other breaking things we should do before we release 5.0?

@RReverser
Copy link
Member

@marijnh Not really. To be honest, I've opposed this one for a while in early stages, as it's quite a breaking change, which caused trouble when happened in Esprima/Babylon, but now it's probably fine to have it just for the sake of compat.

@marijnh
Copy link
Member

marijnh commented Feb 16, 2017

@RReverser I read the thread, and I agree with your reasoning there, but as you said, the standard seems to have moved on, so I guess we should follow.

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