-
Notifications
You must be signed in to change notification settings - Fork 33
/
test.ts
31 lines (25 loc) · 894 Bytes
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Project } from "ts-morph";
const tsAstProject = new Project();
const sourceFile = tsAstProject.createSourceFile('testfile.js', getSourceText());
// Just calling the below method is what causes the problem when moving later.
// If this line is commented out, the move succeeds.
sourceFile.getClass( 'TableHeader' )!;
sourceFile.move('testfile.tsx');
function getSourceText() {
return `
class TableHeader extends React.Component {
renderHeader() {
const mapArr = this.props.columns
.map(columnDef => (
<div>
{(columnDef.sort !== false)
? 'test'
: 'title'
}
</div>
));
return mapArr;
}
}
`;
}