goscript 0.0.71 → 0.0.74

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.
@@ -913,26 +913,26 @@ function compareTypeStringWithTypeInfo(
913
913
  if (!elemType) {
914
914
  return false
915
915
  }
916
-
916
+
917
917
  // Handle struct types
918
918
  if (elemStr.startsWith('struct{')) {
919
919
  const elemTypeInfo = normalizeTypeInfo(elemType)
920
920
  if (!isStructTypeInfo(elemTypeInfo)) {
921
921
  return false
922
922
  }
923
-
923
+
924
924
  // For anonymous structs, compare the type string representation
925
925
  // Extract field definitions from the string
926
926
  const fieldsMatch = elemStr.match(/^struct{(.+)}$/)
927
927
  if (!fieldsMatch) {
928
928
  return false
929
929
  }
930
-
930
+
931
931
  const fieldStr = fieldsMatch[1]
932
932
  // Parse fields like "Name string" or "X int; Y string"
933
- const fieldParts = fieldStr.split(';').map(s => s.trim())
933
+ const fieldParts = fieldStr.split(';').map((s) => s.trim())
934
934
  const parsedFields: Record<string, string> = {}
935
-
935
+
936
936
  for (const part of fieldParts) {
937
937
  // Handle "Name string" format
938
938
  const match = part.match(/^(\w+)\s+(.+)$/)
@@ -941,30 +941,29 @@ function compareTypeStringWithTypeInfo(
941
941
  parsedFields[fieldName] = fieldType.trim()
942
942
  }
943
943
  }
944
-
944
+
945
945
  // Compare fields
946
946
  const typeInfoFields = elemTypeInfo.fields || {}
947
947
  const typeInfoFieldNames = Object.keys(typeInfoFields)
948
948
  const parsedFieldNames = Object.keys(parsedFields)
949
-
949
+
950
950
  if (typeInfoFieldNames.length !== parsedFieldNames.length) {
951
951
  return false
952
952
  }
953
-
953
+
954
954
  // Check if all field names match and types are compatible
955
955
  for (const fieldName of typeInfoFieldNames) {
956
956
  if (!(fieldName in parsedFields)) {
957
957
  return false
958
958
  }
959
-
959
+
960
960
  const fieldValue = typeInfoFields[fieldName]
961
961
  // Handle StructFieldInfo (which has 'type' and optional 'tag' properties)
962
- const fieldTypeInfo: TypeInfo | string = isStructFieldInfo(fieldValue)
963
- ? fieldValue.type
964
- : fieldValue
962
+ const fieldTypeInfo: TypeInfo | string =
963
+ isStructFieldInfo(fieldValue) ? fieldValue.type : fieldValue
965
964
  const typeInfoFieldType = normalizeTypeInfo(fieldTypeInfo)
966
965
  const parsedFieldType = parsedFields[fieldName]
967
-
966
+
968
967
  // Compare basic types
969
968
  if (isBasicTypeInfo(typeInfoFieldType)) {
970
969
  const expectedTypeName = typeInfoFieldType.name || ''
@@ -972,17 +971,19 @@ function compareTypeStringWithTypeInfo(
972
971
  if (expectedTypeName === 'string' && parsedFieldType === 'string') {
973
972
  continue
974
973
  }
975
- if ((expectedTypeName === 'int' || expectedTypeName === 'number') &&
976
- (parsedFieldType === 'int' || parsedFieldType === 'number')) {
974
+ if (
975
+ (expectedTypeName === 'int' || expectedTypeName === 'number') &&
976
+ (parsedFieldType === 'int' || parsedFieldType === 'number')
977
+ ) {
977
978
  continue
978
979
  }
979
980
  return false
980
981
  }
981
982
  }
982
-
983
+
983
984
  return true
984
985
  }
985
-
986
+
986
987
  // Handle named types
987
988
  if (typeof elemType === 'string') {
988
989
  return elemStr === elemType
@@ -991,7 +992,7 @@ function compareTypeStringWithTypeInfo(
991
992
  return elemStr === elemType.name
992
993
  }
993
994
  }
994
-
995
+
995
996
  return false
996
997
  }
997
998
 
@@ -1009,7 +1010,7 @@ export function typeAssert<T>(
1009
1010
  typeInfo: string | TypeInfo,
1010
1011
  ): TypeAssertResult<T> {
1011
1012
  const normalizedType = normalizeTypeInfo(typeInfo)
1012
-
1013
+
1013
1014
  // Handle typed nil pointers (created by typedNil() for conversions like (*T)(nil))
1014
1015
  if (typeof value === 'object' && value !== null && value.__isTypedNil) {
1015
1016
  // For typed nils, we need to compare the stored type with the expected type
@@ -1023,7 +1024,7 @@ export function typeAssert<T>(
1023
1024
  }
1024
1025
  return { value: null as unknown as T, ok: false }
1025
1026
  }
1026
-
1027
+
1027
1028
  if (isPointerTypeInfo(normalizedType) && value === null) {
1028
1029
  return { value: null as unknown as T, ok: true }
1029
1030
  }
@@ -1208,7 +1209,7 @@ export function typeSwitch(
1208
1209
  * Creates a typed nil pointer with type metadata for reflection.
1209
1210
  * This is used for type conversions like (*Interface)(nil) where we need
1210
1211
  * to preserve the pointer type information even though the value is null.
1211
- *
1212
+ *
1212
1213
  * @param typeName The full Go type name (e.g., "*main.Stringer")
1213
1214
  * @returns An object that represents a typed nil with reflection metadata
1214
1215
  */
package/gs/reflect/map.ts CHANGED
@@ -1,4 +1,11 @@
1
- import { Type, Kind, Value, Map as MapKind, StructField, TypeOf } from './type.js'
1
+ import {
2
+ Type,
3
+ Kind,
4
+ Value,
5
+ Map as MapKind,
6
+ StructField,
7
+ TypeOf,
8
+ } from './type.js'
2
9
 
3
10
  // Simple MapOf implementation using JavaScript Map
4
11
  export function MapOf(key: Type, elem: Type): Type {
@@ -1580,7 +1580,9 @@ class StructType implements Type {
1580
1580
 
1581
1581
  public Field(i: number): StructField {
1582
1582
  if (i < 0 || i >= this.NumField()) {
1583
- throw new Error(`reflect: Field index out of range [${i}] with length ${this.NumField()}`)
1583
+ throw new Error(
1584
+ `reflect: Field index out of range [${i}] with length ${this.NumField()}`,
1585
+ )
1584
1586
  }
1585
1587
  const f = this._fields[i]
1586
1588
  return new StructField({
@@ -1676,12 +1678,16 @@ class StructType implements Type {
1676
1678
  }
1677
1679
  case 'slice':
1678
1680
  if (ti.elemType) {
1679
- return new SliceType(StructType.createTypeFromFieldInfo(ti.elemType))
1681
+ return new SliceType(
1682
+ StructType.createTypeFromFieldInfo(ti.elemType),
1683
+ )
1680
1684
  }
1681
1685
  return new SliceType(new BasicType(Invalid, 'unknown', 8))
1682
1686
  case 'pointer':
1683
1687
  if (ti.elemType) {
1684
- return new PointerType(StructType.createTypeFromFieldInfo(ti.elemType))
1688
+ return new PointerType(
1689
+ StructType.createTypeFromFieldInfo(ti.elemType),
1690
+ )
1685
1691
  }
1686
1692
  return new PointerType(new BasicType(Invalid, 'unknown', 8))
1687
1693
  case 'interface':
@@ -97,7 +97,6 @@ export class stringFinder {
97
97
  for (
98
98
  ;
99
99
  j >= 0 && $.indexString(text, i) == $.indexString(f!.pattern, j);
100
-
101
100
  ) {
102
101
  i--
103
102
  j--
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.71",
4
+ "version": "0.0.74",
5
5
  "author": {
6
6
  "name": "Aperture Robotics LLC.",
7
7
  "email": "support@aperture.us",