facebook / facebook/jscodeshift
Creates syntax error when transforming Flow types without identifier
Open
bug
- Dominant language
- JavaScript
- Stars
- 10k
- Forks
- 498
- PR merge metrics
- No merged PRs in 30d
Description
In certain cases jscodeshift causes a syntax error when transforming types (in my case Flow, but maybe TS, too). [Seee this demo.](https://astexplorer.net/#/gist/874f58d515c1962bed232b6020fb909c/c935a97c13a94d95801e8d5669c35ff3d71664f8)
Transform:
```js
export default function transformer(file, api) {
const j = api.jscodeshift;
const root = j(file.source);
return root
.find(j.StringTypeAnnotation)
.replaceWith(j.numberTypeAnnotation())
.toSource()
}
export const parser = 'flow'
```
Source:
```js
type Ob = {
[string]: number,
}
```
Result:
```js
type Ob = {
[: number]: number,
}
```
Contributor guide
Assessment
This issue has not been assessed yet.