facebook / facebook/jscodeshift
template.statements breaks TypeScript namespaces
- Vorherrschende Sprache
- JavaScript
- Sterne
- 10k
- Forks
- 498
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
[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; }
}
```
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.