swc-project / swc

Rust-based platform for the Web
https://swc.rs
Apache License 2.0
31.17k stars 1.23k forks source link

[types] - ctxt attribute #9564

Open sla100 opened 1 month ago

sla100 commented 1 month ago

Type declarations claims that ctxt attribute are part of span object: https://github.com/swc-project/swc/blob/85cc2bd79c3193cb0a8b54e4fce0efc1aa15b271/packages/types/index.ts#L1163C1-L1167C2

But in fact there are located placed next to each other:

input:

let a;

AST:

{
  "body": [
    {
      "type": "VariableDeclaration",
      "span": {
        "start": 0,
        "end": 6
      },
      "ctxt": 0
    }
  ]
}
kdy1 commented 1 month ago

Actually we don't recommend using parse from JS.