@zyno-io/ts-reflection 26.1005.1121 → 26.1009.210

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.
@@ -299,9 +299,12 @@ func genericTypeExpr(info *fileInfo, reg *registry, name string, args []string,
299
299
  for i := range alias.params {
300
300
  out = replaceTypeParameter(out, aliasParamName(alias, i), aliasArg(alias, args, i))
301
301
  }
302
- if hasUnresolvedTypeParameters(out, alias.params) || isUnsupportedTypeSyntax(out) {
302
+ if hasUnresolvedTypeParameters(out, alias.params) {
303
303
  return "{kind: 2, typeName: " + quote(name) + ", typeArguments: [" + mapJoin(args, func(arg string) string { return typeExprCtx(info, reg, arg, ctx) }) + "]}"
304
304
  }
305
+ // Let the type encoder classify the instantiated body. Its supported
306
+ // object, tuple, array, and generic syntax also contains brackets and
307
+ // colons; the unsupported-syntax fallback runs after those cases.
305
308
  return withTypeName(typeExprCtx(owner, reg, out, ctx), name)
306
309
  }
307
310
  if decl, owner, _, ok := resolveInterfaceDeclRefAt(info, reg, name, ctx.pos); ok {
@@ -838,9 +838,6 @@ func hasPreferredTypiaBlockerSyntaxDeep(info *fileInfo, reg *registry, raw strin
838
838
  }
839
839
  return false
840
840
  }
841
- if strings.Contains(raw, "[") || strings.Contains(raw, "]") {
842
- return false
843
- }
844
841
  if name, args, ok := generic(raw); ok {
845
842
  if (name == "Pattern" || name == "Validate") && (len(args) == 0 || !isLiteralStringType(args[0])) {
846
843
  return true
@@ -892,6 +889,12 @@ func hasPreferredTypiaBlockerSyntaxDeep(info *fileInfo, reg *registry, raw strin
892
889
  }
893
890
  return false
894
891
  }
892
+ // Inspect the generic itself before treating brackets as checker-resolved
893
+ // indexed access. A tuple in its options must not erase runtime metadata
894
+ // (for example FileUpload<{ allowedTypes: ['image/png'] }>).
895
+ if strings.Contains(raw, "[") || strings.Contains(raw, "]") {
896
+ return false
897
+ }
895
898
  if isIdentifierName(raw) {
896
899
  if alias, owner, _, ok := resolveAliasRef(info, reg, raw); ok {
897
900
  return hasPreferredTypiaBlockerSyntaxDeep(owner, reg, alias.body, root, alias.pos, seen)
@@ -0,0 +1,34 @@
1
+ package main
2
+
3
+ import "testing"
4
+
5
+ func TestUploadAliasesWithTupleOptionsKeepInternalMetadata(t *testing.T) {
6
+ info, reg := testTypeInfo()
7
+ info.aliases["ImageUpload"] = aliasInfo{body: "FileUpload<{ maxSize: '128B'; allowedTypes: ['image/png'] }>"}
8
+ info.aliases["ChainedUpload"] = aliasInfo{body: "ImageUpload"}
9
+ for _, raw := range []string{
10
+ "FileUpload<{ allowedTypes: ['image/png'] }>",
11
+ "ImageUpload", "ChainedUpload", "ImageUpload[]",
12
+ "{ attachments?: ImageUpload[] }",
13
+ "HttpBody<{ attachments?: ImageUpload[] }>",
14
+ } {
15
+ if canPreferTypiaTypeOnPreferredSurface(info, reg, raw) {
16
+ t.Errorf("upload constructor/options must not be erased on preferred surface: %s", raw)
17
+ }
18
+ }
19
+ if !canPreferTypiaTypeOnPreferredSurface(info, reg, "Source['items'][number]") {
20
+ t.Fatal("indexed access must remain checker-resolved")
21
+ }
22
+ }
23
+ func TestGenericUploadAliasKeepsInstantiatedPolicy(t *testing.T) {
24
+ info, reg := testTypeInfo()
25
+ info.aliases["GenericUpload"] = aliasInfo{
26
+ params: []string{"Types"},
27
+ body: "FileUpload<{ maxSize: '128B'; allowedTypes: Types }>",
28
+ }
29
+ expr := typeExpr(info, reg, "GenericUpload<['image/png']>")
30
+ assertContainsAll(t, expr, "kind: 16", "classType:", "FileUpload", "typeArguments:", "name: \"allowedTypes\"", "literal: \"image/png\"")
31
+ if canPreferTypiaTypeOnPreferredSurface(info, reg, "GenericUpload<['image/png']>") {
32
+ t.Fatal("generic upload aliases must retain runtime metadata")
33
+ }
34
+ }
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@zyno-io/ts-reflection",
3
- "version": "26.1005.1121",
3
+ "version": "26.1009.210",
4
4
  "description": "Browser-neutral TypeScript reflection and runtime metadata",
5
5
  "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/zyno-io/ts-server-foundation.git",
9
+ "directory": "packages/reflection"
10
+ },
6
11
  "files": [
7
12
  "dist/",
8
13
  "package.json",