You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/building-with-codegen/exports.mdx
+47-40Lines changed: 47 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,8 @@ iconType: "solid"
7
7
8
8
The [Export](/api-reference/core/Export) API provides tools for managing exports and module boundaries in TypeScript codebases.
9
9
10
+
<Note>Exports are a TS-only language feature</Note>
11
+
10
12
## Export Statements vs Exports
11
13
12
14
Similar to imports, Codegen provides two levels of abstraction for working with exports:
@@ -30,19 +32,54 @@ export function process() {}
30
32
You can access these through your file's collections:
31
33
32
34
```python
35
+
# Access all exports in the codebase
36
+
for export in codebase.exports:
37
+
...
38
+
33
39
# Access all export statements
34
40
for stmt infile.export_statements:
35
-
print(f"Statement: {stmt.source}")
36
-
37
-
# Access individual exports in the statement
38
41
for exp in stmt.exports:
39
-
print(f" Export: {exp.name}")
42
+
...
40
43
```
41
44
42
45
<Note>
43
46
ExportStatement inherits from [Statement](/building-with-codegen/statements-and-code-blocks), providing operations like `remove()` and `insert_before()`. This is particularly useful when you want to manipulate the entire export declaration.
44
47
</Note>
45
48
49
+
## Common Operations
50
+
51
+
Here are common operations for working with exports:
0 commit comments