goscript 0.0.31 → 0.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -378,6 +378,60 @@ func (c *GoToTSCompiler) WriteCallExpr(exp *ast.CallExpr) error {
378
378
  c.tsw.WriteLiterally(")")
379
379
  return nil // Handled make for named slice type
380
380
  }
381
+
382
+ // Handle named types with map underlying types: make(NamedMapType)
383
+ if mapType, isMap := namedType.Underlying().(*types.Map); isMap {
384
+ c.tsw.WriteLiterally("$.makeMap<")
385
+ c.WriteGoType(mapType.Key(), GoTypeContextGeneral) // Write the key type
386
+ c.tsw.WriteLiterally(", ")
387
+ c.WriteGoType(mapType.Elem(), GoTypeContextGeneral) // Write the value type
388
+ c.tsw.WriteLiterally(">()")
389
+ return nil // Handled make for named map type
390
+ }
391
+
392
+ // Handle named types with channel underlying types: make(NamedChannelType, bufferSize)
393
+ if chanType, isChan := namedType.Underlying().(*types.Chan); isChan {
394
+ c.tsw.WriteLiterally("$.makeChannel<")
395
+ c.WriteGoType(chanType.Elem(), GoTypeContextGeneral)
396
+ c.tsw.WriteLiterally(">(")
397
+
398
+ // If buffer size is provided, add it
399
+ if len(exp.Args) >= 2 {
400
+ if err := c.WriteValueExpr(exp.Args[1]); err != nil {
401
+ return fmt.Errorf("failed to write buffer size in makeChannel: %w", err)
402
+ }
403
+ } else {
404
+ // Default to 0 (unbuffered channel)
405
+ c.tsw.WriteLiterally("0")
406
+ }
407
+
408
+ c.tsw.WriteLiterally(", ") // Add comma for zero value argument
409
+
410
+ // Write the zero value for the channel's element type
411
+ if chanType.Elem().String() == "struct{}" {
412
+ c.tsw.WriteLiterally("{}")
413
+ } else {
414
+ c.WriteZeroValueForType(chanType.Elem())
415
+ }
416
+
417
+ // Add direction parameter
418
+ c.tsw.WriteLiterally(", ")
419
+
420
+ // Determine channel direction
421
+ switch chanType.Dir() {
422
+ case types.SendRecv:
423
+ c.tsw.WriteLiterally("'both'")
424
+ case types.SendOnly:
425
+ c.tsw.WriteLiterally("'send'")
426
+ case types.RecvOnly:
427
+ c.tsw.WriteLiterally("'receive'")
428
+ default:
429
+ c.tsw.WriteLiterally("'both'") // Default to bidirectional
430
+ }
431
+
432
+ c.tsw.WriteLiterally(")")
433
+ return nil // Handled make for named channel type
434
+ }
381
435
  }
382
436
  }
383
437
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "goscript",
3
3
  "description": "Go to TypeScript transpiler",
4
- "version": "0.0.31",
4
+ "version": "0.0.32",
5
5
  "author": {
6
6
  "name": "Aperture Robotics LLC.",
7
7
  "email": "support@aperture.us",