facebook / jscodeshift

A JavaScript codemod toolkit.
https://jscodeshift.com
MIT License
9.11k stars 468 forks source link

Declaration has "null" loc field when inside export #558

Closed slonoed closed 9 months ago

slonoed commented 1 year ago

Happens with jscodeshift@0.14

Simplest demonstration

This returns null

require('jscodeshift')('export const a = 1').nodes()[0].program.body[0].declaration.loc

While this returns proper location

require('jscodeshift')('const a = 1').nodes()[0].program.body[0].loc

Same happens when exporting class

ElonVolo commented 1 year ago

This seems like old recast bug from five years ago that has yet to be fixed.https://github.com/benjamn/recast/issues/557Sent from my iPhoneOn May 12, 2023, at 18:57, Dmitry Manannikov @.> wrote: Happens with @. Simplest demonstration This returns null require('jscodeshift')('export const a = 1').nodes()[0].program.body[0].declaration.loc

While this returns proper location require('jscodeshift')('const a = 1').nodes()[0].program.body[0].loc

Same happens when exporting class

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>