@@ -64,6 +64,41 @@ npm install -g goscript
64
64
goscript compile --package . --output ./dist
65
65
```
66
66
67
+ ## 📦 Using Generated Code in Your Project
68
+
69
+ After compiling your Go code to TypeScript, you'll need to set up your project to consume the generated files.
70
+
71
+ ### TypeScript Configuration
72
+
73
+ Create or update your ` tsconfig.json ` with these settings:
74
+
75
+ ``` json
76
+ {
77
+ "compilerOptions" : {
78
+ "target" : " ES2022" ,
79
+ "module" : " ESNext" ,
80
+ "moduleResolution" : " bundler" ,
81
+ "lib" : [" ES2022" , " esnext.disposable" , " dom" ],
82
+ "baseUrl" : " ./" ,
83
+ "paths" : {
84
+ "@goscript/*" : [" ./path/to/generated/output/@goscript/*" ]
85
+ },
86
+ "allowSyntheticDefaultImports" : true ,
87
+ "esModuleInterop" : true ,
88
+ "skipLibCheck" : true ,
89
+ "strict" : true
90
+ }
91
+ }
92
+ ```
93
+
94
+ ** Important requirements:**
95
+ - ** ` target: "ES2022" ` or newer** - Required for ` Disposable ` and other features
96
+ - ** ` lib: ["esnext.disposable"] ` ** - Enables TypeScript's disposable types for resource management
97
+ - ** ` baseUrl ` and ` paths ` ** - Allows TypeScript to resolve ` @goscript/* ` imports
98
+ - ** ` moduleResolution: "bundler" ` ** - Recommended for modern bundlers
99
+
100
+ You should be able to use any TypeScript bundler to compile the generated TypeScript.
101
+
67
102
## 💡 See It In Action
68
103
69
104
### Example: User Management
@@ -276,19 +311,7 @@ const searchUser = (email: string) => {
276
311
- ⚡ Performance optimizations
277
312
- 🔧 Better tooling integration
278
313
279
- Check our [ compliance tests] ( ./compliance/COMPLIANCE.md ) for detailed progress.
280
-
281
- ## 🤝 Real-World Use Cases
282
-
283
- ** Fintech:** Share complex financial calculations between Go services and trading dashboards
284
-
285
- ** Gaming:** Run the same game logic on servers and in browser clients
286
-
287
- ** Data Processing:** Use identical algorithms for backend ETL and frontend analytics
288
-
289
- ** Validation:** Keep business rules consistent across your entire stack
290
-
291
- Ready to eliminate code duplication? [ Get started now] ( #-get-started-in-2-minutes ) 🚀
314
+ Check the [ compliance tests] ( ./compliance/COMPLIANCE.md ) for detailed progress.
292
315
293
316
## License
294
317
0 commit comments