@zyno-io/ts-reflection 26.813.636 → 26.813.2308

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.
@@ -230,6 +230,24 @@ func TestTypeExprRendersLiteralArrayTypes(t *testing.T) {
230
230
  }
231
231
  }
232
232
 
233
+ func TestInterfacePropertyPreservesUnionWithAnArrayMember(t *testing.T) {
234
+ file := parseTestSourceFile(t, "/project/union-array-property.ts", `
235
+ interface ScalarOrArrayValue {
236
+ value: string | string[];
237
+ }
238
+ `)
239
+ decl := interfaceFromNode(file, file.Statements.Nodes[0])
240
+ info, reg := testTypeInfo()
241
+ info.file = file
242
+
243
+ property := decl.properties[0]
244
+ got := typeExprForNodePreferred(info, reg, property.typeText, property.typeNode, decl.pos, true)
245
+ want := `{kind: 12, types: [{kind: 6}, {kind: 14, type: {kind: 6}}]}`
246
+ if got != want {
247
+ t.Fatalf("scalar-or-array property metadata = %s, want %s", got, want)
248
+ }
249
+ }
250
+
233
251
  func TestTypeExprForNodeUsesAstUnionMemberOrder(t *testing.T) {
234
252
  file := parseTestSourceFile(t, "/project/ordered-union.ts", `
235
253
  type Status =
@@ -453,6 +453,9 @@ func cachedTypeExpr(info *fileInfo, reg *registry, raw string, node *shimast.Nod
453
453
 
454
454
  func preferredWrapperTypeExprForNode(info *fileInfo, reg *registry, raw string, node *shimast.Node, pos int) (string, bool) {
455
455
  raw = strings.TrimSpace(trimParens(raw))
456
+ if len(nonEmptyParts(splitTop(raw, "|"))) > 1 || len(nonEmptyParts(splitTop(raw, "&"))) > 1 {
457
+ return "", false
458
+ }
456
459
  if strings.HasSuffix(raw, "[]") {
457
460
  element := strings.TrimSpace(strings.TrimSuffix(raw, "[]"))
458
461
  return "{kind: 14, type: " + typeExprForNodePreferred(info, reg, element, nil, pos, true) + "}", true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyno-io/ts-reflection",
3
- "version": "26.813.636",
3
+ "version": "26.813.2308",
4
4
  "description": "Browser-neutral TypeScript reflection and runtime metadata",
5
5
  "license": "MIT",
6
6
  "files": [