Skip to content

Language Extensions #120

@jamiebuilds

Description

@jamiebuilds

Much of the tooling in the ecosystem needs to work with language extensions like JSX and Flow, and forks like TypeScript.

Shift is really nice to work with, but is limited to things that have been accepted into ECMAScript. It would be nice if it could make room for extensions to exist much like ESTree does and document them.

Even further than that I was hoping Shift could make some relatively simple changes to make room for a better ASTs for Flow and TypeScript...


<aside>

For example, adding a ClassExtends node would help a lot:

// before
ClassDeclaration {
  super: Expression
  superTypeArguments: TypeArguments // extension
}
// after
ClassDeclaration {
  super: ClassExtends {
    expression: Expression
    typeArguments: TypeArguments // extension
  }
}

This would really useful because ClassExtends could have the same implemented interface "ExpressionWithTypeArguments" as stuff like ClassImplements and InterfaceExtends and GenericType which would otherwise be totally separate cases to handle.

In terms of the changes to Shift, it would just be adding an "extra" node type with a single property expression, but would make for a much nicer AST when working with types.

</aside>


I'm writing a spec for an AST right now that unifies Flow and TypeScript into something really nice to work with. It builds upon a lot of the work in Shift and trying to keep up some of the design decisions.

If people would be up for it, I would love to make specific requests for extension points in the Shift AST which can be discussed individually.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions