typespec-http-zod 0.20.0 → 0.21.0

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/api.js +17 -3
  2. package/package.json +1 -1
package/dist/src/api.js CHANGED
@@ -1659,8 +1659,21 @@ function renderRequestTypes(entries, responses, registry) {
1659
1659
  const lookup = entries
1660
1660
  .map((entry) => `\t${entry.operationId}: ${upperFirst(entry.operationId)}Input;`)
1661
1661
  .join("\n");
1662
- return `${generatedBanner()}
1663
- /**
1662
+ /**
1663
+ * **Emitted only where an operation has something to flatten.**
1664
+ *
1665
+ * A generated file has to pass the lint of whatever project it lands in, and `noUnusedLocals`
1666
+ * makes an unused type declaration an error. A service whose operations take no input at all -
1667
+ * two parameterless `GET`s, which is where a health check starts and therefore where every new
1668
+ * consumer starts - got this declaration and no use of it, so `requests.gen.ts` did not compile.
1669
+ * `TS6196: 'Simplify' is declared but never used.` Third of its kind, after the unconditional
1670
+ * `zValidator` and `z` imports.
1671
+ *
1672
+ * Decided from the aliases actually rendered rather than by searching the output for the name.
1673
+ */
1674
+ const simplifyHelper = inputs.length === 0
1675
+ ? ""
1676
+ : `/**
1664
1677
  * Flattens an intersection into a single object type.
1665
1678
  *
1666
1679
  * Without it, \`Body & { filingId: string }\` and the equivalent flat object are structurally the
@@ -1668,7 +1681,8 @@ function renderRequestTypes(entries, responses, registry) {
1668
1681
  * this file with the emitted Zod would fail on correct code.
1669
1682
  */
1670
1683
  type Simplify<T> = { [K in keyof T]: T[K] } & {};
1671
-
1684
+ `;
1685
+ return `${generatedBanner()}${simplifyHelper}
1672
1686
  /**
1673
1687
  * The same shape, tolerant of \`readonly\`.
1674
1688
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typespec-http-zod",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "TypeSpec emitter and library: turn an HTTP service definition into Zod validators and framework-free contract types that agree, keyword for keyword, with the OpenAPI document @typespec/openapi3 publishes from the same source.",
5
5
  "keywords": [
6
6
  "codegen",