typespec-hono 0.18.0 → 0.18.1

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.
Files changed (2) hide show
  1. package/dist/src/app.js +24 -8
  2. package/package.json +2 -2
package/dist/src/app.js CHANGED
@@ -429,7 +429,11 @@ securityFor) {
429
429
  *
430
430
  * - an index signature, which an open model infers because its validator really does pass unknown
431
431
  * keys through. TypeScript gives an interface no implicit index signature, so returning one meant
432
- * spreading every level of the tree - a structural deep copy per response on one real service;
432
+ * spreading every level of the tree - a structural deep copy per response on one real service.
433
+ * **Only where the shape has declared keys beside it**: an index signature also arrives as a
434
+ * property's own declared type (\`Record<unknown>\`), where it is stated identically in both
435
+ * artefacts and stripping it would destroy the property. A string indexer means "dictionary" only
436
+ * when nothing is declared next to it, which is the same rule the contract types use;
433
437
  * - \`readonly\`, which a codebase commonly puts on the views its layers hand back. \`readonly T[]\`
434
438
  * and \`T[]\` serialise to identical bytes, so mutability says nothing about a payload.
435
439
  *
@@ -443,20 +447,32 @@ securityFor) {
443
447
  * Returning extra properties still works - excess-property checks apply to object literals, not to a
444
448
  * value the application already holds.
445
449
  */
450
+ type ProducedKeyOf<T> = keyof {
451
+ [K in keyof T as string extends K
452
+ ? never
453
+ : number extends K
454
+ ? never
455
+ : symbol extends K
456
+ ? never
457
+ : K]: 0;
458
+ };
459
+
446
460
  type Produced<T> = T extends (...args: never[]) => unknown
447
461
  ? T
448
462
  : T extends readonly (infer Element)[]
449
463
  ? readonly Produced<Element>[]
450
464
  : T extends object
451
- ? {
452
- readonly [K in keyof T as string extends K
453
- ? never
454
- : number extends K
465
+ ? [ProducedKeyOf<T>] extends [never]
466
+ ? { readonly [K in keyof T]: Produced<T[K]> }
467
+ : {
468
+ readonly [K in keyof T as string extends K
455
469
  ? never
456
- : symbol extends K
470
+ : number extends K
457
471
  ? never
458
- : K]: Produced<T[K]>;
459
- }
472
+ : symbol extends K
473
+ ? never
474
+ : K]: Produced<T[K]>;
475
+ }
460
476
  : T;
461
477
 
462
478
  `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typespec-hono",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "TypeSpec emitter: generate a Hono server, and the Zod validators it enforces, from an HTTP service definition, agreeing with the OpenAPI document @typespec/openapi3 publishes from the same source.",
5
5
  "keywords": [
6
6
  "cloudflare-workers",
@@ -44,7 +44,7 @@
44
44
  "provenance": true
45
45
  },
46
46
  "dependencies": {
47
- "typespec-http-zod": "^0.19.0"
47
+ "typespec-http-zod": "^0.19.1"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@hono/zod-openapi": "^1.4.0",