benjamn / benjamn/recast

[flow-parser] when adding an import specifier to "import {type foo}", the "type" from "type foo" disappears when reprinting

Open
#839 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.3k
Forks
363
Avg merge
3d 8h
Merged PRs (30d)
3

Description

This happens only with `flow-parser`.

If I have `import { type foo } from 'foo'`, and I add the import specifier `bar` to it, I would expect the resulting code to be `import { type foo, bar } from 'foo'`, but the `type` disappears and it prints `import { foo, bar } from 'foo'`.

When I reprint the AST before modifying it the `type` is still there.

### Reproduction repo

https://github.com/jedwards1211/recast-flow-parser-imports-issue

### Package Versions
```json
{
"ast-types": "0.14.2",
"flow-parser": "0.141.0",
"recast": "0.20.4"
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked reproduction repo using the listed ast-types, flow-parser, and recast versions, then trace the import-specifier modification and reprint path. Done means reprinting `import { type foo }` after adding `bar` preserves `type`, producing `import { type foo, bar } from 'foo'`.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.