forked from TheLartians/TypeScript2Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseExports.ts
More file actions
24 lines (22 loc) 路 758 Bytes
/
Copy pathparseExports.ts
File metadata and controls
24 lines (22 loc) 路 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import ts from "typescript";
import { ParserState } from "./ParserState";
import { parseTypeDefinition } from "./parseTypeDefinition";
import { Ts2PyConfig } from "./config";
export function parseExports(state: ParserState, sourceFile: ts.SourceFile) {
for (const statement of sourceFile.statements) {
if (
ts.isTypeAliasDeclaration(statement) ||
ts.isInterfaceDeclaration(statement)
) {
const isExported = !!(
ts.getCombinedModifierFlags(statement) & ts.ModifierFlags.Export
);
if (isExported) {
const name = statement.name.getText();
const type = state.typechecker.getTypeAtLocation(statement);
parseTypeDefinition(state, name, type);
}
}
}
return state.statements;
}