oxc-project / oxc

⚓ A collection of JavaScript tools written in Rust.
https://oxc.rs
MIT License
11.99k stars 432 forks source link

Convention for field order in AST types #6453

Open overlookmotel opened 1 week ago

overlookmotel commented 1 week ago

I opened #6391 to re-order fields on some types so they're in source order. I had assumed:

Our convention is that AST type fields are ordered in order they appear in source.

@Boshen replied:

In source or runtime order? This should be documented.

Opening this issue to resolve question of what is our convention, so that we can document it.

A couple of questions:

  1. What does "runtime order" mean exactly? The order of runtime evaluation?

  2. Are there any cases where source order and runtime order are different? I can't immediately think of any, but JS is weird - there may well be some obscure cases where they're different.

Boshen commented 1 week ago

Evaluation order defined in the spec. For types, we look at how it's defined in tsc.

overlookmotel commented 1 week ago

Reopening this just for the action point of adding this info to the docs.