JavaScript: moving an import joins it into one under `// @ts-ignore`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, typescript
- Domain
- devtools
Research direction
The join logic is in rewrite-javascript/rewrite/src/javascript/recipes/change-import.ts, where ChangeImport merges a moved member into an existing import from the target module. Start there and check whether the comment directly above that import is considered. Reproduce with oldModule ./old.ts, oldMember a, newModule ./m.ts on the before example. Done when the moved member gets its own statement under the ts-ignore comment and merging into unrelated imports still works as before.
Written by the indexing model from the issue text.
Description
Potentially related:
- #9789: the same join ignores import attributes
ChangeImport (org.openrewrite.javascript.change-import) joins a moved member into an existing import of the target module even when a // @ts-ignore sits above that import. The directive then also hides errors for the moved member, such as the target module not exporting it, which is the error a move most needs to surface.
Verified on 8d2c9b668a with new ChangeImport({oldModule: "./old.ts", oldMember: "a", newModule: "./m.ts"}).
1. Moved member joined under // @ts-ignore
Before
import {a} from "./old.ts";
// @ts-ignore
import {b} from "./m.ts";
a(b);
After (problem)
// @ts-ignore
import {a, b} from "./m.ts";
a(b);
After (expected)
import {a} from "./m.ts";
// @ts-ignore
import {b} from "./m.ts";
a(b);
Expected rule: don't join a moved or added member into an import directly below // @ts-ignore or // @ts-expect-error; keep or add a statement of its own.
- Dominant language
- Java
- Stars
- 3.9k
- Forks
- 599
- Avg merge
- 9h 38m
- Merged PRs (30d)
- 557
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openrewrite/rewrite
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
openrewrite/rewrite#9835 ·
Maintainers usually reply within 1 day
-
bug gradle
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
openrewrite/rewrite#7576 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
openrewrite/rewrite#9834 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
openrewrite/rewrite#9819 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 55/100
openrewrite/rewrite#9817 ·
Maintainers usually reply within 1 day
All issues in openrewrite/rewrite
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
SasanLabs/VulnerableApp#912 ·
Maintainers usually reply within 1 day
-
area/build area/events area/storage area/storage/kafkasql area/storage/sql
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Apicurio/apicurio-registry#11079 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenAEV-Platform/openaev#9139 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
desktop edt not responding
Difficulty 2/5 1-3 hours Newbie friendliness 78/100