Skip to content

docs: document reusing a property's type via leaf types#222

Open
1chooo wants to merge 1 commit into
google:mainfrom
1chooo:docs/leaf-property
Open

docs: document reusing a property's type via leaf types#222
1chooo wants to merge 1 commit into
google:mainfrom
1chooo:docs/leaf-property

Conversation

@1chooo

@1chooo 1chooo commented Jul 15, 2026

Copy link
Copy Markdown

Summary

Indexing a union alias like Organization to reuse a single property's type
fails, because the alias also includes an id-reference string that has no
properties (the workaround was Exclude<Organization, string>['image']). Since
v2.0.0, schema-dts exports concrete ...Leaf interfaces, so you can index them
directly: OrganizationLeaf['image']. This documents that.

Relates to #50.

Changes

  • README: new "Reusing a property's type" section.
  • Added packages/schema-dts/test/leaf_property.ts compile-time test asserting
    the extracted property types work.

Test plan

  • npm run build
  • tsc -p packages/schema-dts/test/ passes
  • eslint + prettier clean

I have signed / will sign the Google CLA per CONTRIBUTING.md.

Made with Cursor

@google-cla

google-cla Bot commented Jul 15, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Add a README section showing that a property's type can be extracted from
a concrete `...Leaf` interface (e.g. `OrganizationLeaf['image']`), avoiding
the `Exclude<Organization, string>[...]` workaround needed when indexing the
union alias. Documents the request in google#50.

Includes a compile-time test asserting the extracted property types work.
@1chooo 1chooo force-pushed the docs/leaf-property branch from 1190948 to 6d373e6 Compare July 15, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant