@zyno-io/ts-reflection 26.811.2115 → 26.813.636

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.
@@ -218,6 +218,18 @@ func TestTypeExprIgnoresCommentsInsideUnions(t *testing.T) {
218
218
  )
219
219
  }
220
220
 
221
+ func TestTypeExprRendersLiteralArrayTypes(t *testing.T) {
222
+ info, reg := testTypeInfo()
223
+
224
+ got := typeExpr(info, reg, "'heplify-wire'[]")
225
+ if got != `{kind: 14, type: {kind: 10, literal: "heplify-wire"}}` {
226
+ t.Fatalf("literal array metadata = %s", got)
227
+ }
228
+ if _, err := parseExpressionTemplate(got); err != nil {
229
+ t.Fatalf("literal array metadata must be valid JavaScript: %v", err)
230
+ }
231
+ }
232
+
221
233
  func TestTypeExprForNodeUsesAstUnionMemberOrder(t *testing.T) {
222
234
  file := parseTestSourceFile(t, "/project/ordered-union.ts", `
223
235
  type Status =
@@ -82,6 +82,9 @@ func typeExprCtx(info *fileInfo, reg *registry, raw string, ctx *typeContext) st
82
82
  if parts := nonEmptyParts(splitTop(raw, "&")); len(parts) > 1 {
83
83
  return "{kind: 13, types: [" + mapJoin(parts, func(part string) string { return typeExprCtx(info, reg, part, ctx) }) + "]}"
84
84
  }
85
+ if strings.HasSuffix(raw, "[]") {
86
+ return "{kind: 14, type: " + typeExprCtx(info, reg, strings.TrimSuffix(raw, "[]"), ctx) + "}"
87
+ }
85
88
  if strings.HasPrefix(raw, "\"") || strings.HasPrefix(raw, "'") {
86
89
  return "{kind: 10, literal: " + normalizeStringLiteral(raw) + "}"
87
90
  }
@@ -91,9 +94,6 @@ func typeExprCtx(info *fileInfo, reg *registry, raw string, ctx *typeContext) st
91
94
  if _, err := strconv.ParseFloat(raw, 64); err == nil {
92
95
  return "{kind: 10, literal: " + raw + "}"
93
96
  }
94
- if strings.HasSuffix(raw, "[]") {
95
- return "{kind: 14, type: " + typeExprCtx(info, reg, strings.TrimSuffix(raw, "[]"), ctx) + "}"
96
- }
97
97
  if strings.HasPrefix(raw, "[") && strings.HasSuffix(raw, "]") {
98
98
  items := splitTop(strings.TrimSpace(raw[1:len(raw)-1]), ",")
99
99
  return "{kind: 15, types: [" + mapJoin(items, func(item string) string {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyno-io/ts-reflection",
3
- "version": "26.811.2115",
3
+ "version": "26.813.636",
4
4
  "description": "Browser-neutral TypeScript reflection and runtime metadata",
5
5
  "license": "MIT",
6
6
  "files": [