facebook / facebook/jscodeshift
template.statements breaks TypeScript namespaces
- Dominant language
- JavaScript
- Stars
- 10k
- Forks
- 498
- PR merge metrics
- No merged PRs in 30d
Description
[AST Explorer](https://astexplorer.net/#/gist/fb1d90bd9d97857af8a7acbc7649dcc3/b81b9bd246ca9a13d7fa2b0e6f1287d42718bae3)
**Input**
```ts
interface Foo { foo: string; }
interface Bar { bar: string; }
```
**Transformation**
```js
export default function transformer(file, api) {
const j = api.jscodeshift.withParser('ts');
return j(file.source)
.find('Program')
.replaceWith( p => j.template.statement`namespace Z { ${p.node.body} }`)
.toSource();
}
```
**Output**
```ts
namespace Z interface Foo { foo: string; }
interface Bar { bar: string; }
```
**Expected**
```ts
namespace Z {
interface Foo { foo: string; }
interface Bar { bar: string; }
}
```
Contributor guide
Assessment
This issue has not been assessed yet.