Skip to content

Cannot call insertAfter or insertBefore on any exported declaration #667

@intrepidOlivia

Description

@intrepidOlivia

I expect to be able to use the insertAfter method on any node, whether it's exported or not. However, this method throws an error if you try to call it on an exported interface declaration:

{ type: ExportNamedDeclaration, start: 65, end: 128, loc: [object Object], exportKind: type, specifiers: , source: null, declaration: [object Object], leadingComments: [object Object], comments: [object Object] } does not match type array

Repro example in AST Explorer: https://astexplorer.net/#/gist/5e9b2c94baf7845deef8a2b7f7062dc3/5b04592aa86629faf848fb85d945bdcfabd52014
(The AST Explorer is using an old version of jscodeshift, but this issue also repros on version 17.3.0)

I don't think this is expected behavior; at least, it's unclear to me what I can do on my end to resolve the issue. Any workaround for this would be welcome.

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