Skip to content

Conversation

@devongovett
Copy link
Member

Part of #865

This adds a script that extracts all of the examples from the docs MDX files into TSX files, and then runs TypeScript over them. This will run in CI. It found a number of issues, such as unused variables, missing props, etc. So far, I have only fixed the existing type errors, adding annotations where needed. Eventually, we can add type annotations to all examples.

We may want to eventually have a toggle to switch between TS and JS. For now, only TS is displayed.

@adobe-bot
Copy link

@adobe-bot

This comment was marked as outdated.


```tsx example render=false
///- begin collapse -///
function ListBox(props) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was unused. The real implementation is in the below example.

<Tabs aria-label="History of Ancient Rome" items={tabs} onSelectionChange={setTabId}>
<TabList>
{item => (
{(item: Tab) => (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are annoying. Because we designed the API with items on Tabs rather than TabList and TabPanels, this will always be unknown by default without an annotation.


function Example() {
let [selected, setSelected] = React.useState(new Set(['cheese']));
let [selected, setSelected] = React.useState<Selection>(new Set(['cheese']));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are annoying, and caused by onSelectionChange which may emit "all" | Set<Key>, but the type of this variable is only inferred to be Set<string> so it always requires an annotation.

…m into docs-ts

# Conflicts:
#	packages/@adobe/react-spectrum/package.json
#	packages/@adobe/react-spectrum/src/index.ts
#	packages/@react-aria/dnd/src/index.ts
#	packages/@react-aria/overlays/docs/useOverlayTrigger.mdx
#	packages/@react-spectrum/autocomplete/src/SearchAutocomplete.tsx
#	packages/@react-spectrum/list/docs/ListView.mdx
#	packages/dev/parcel-transformer-mdx-docs/MDXTransformer.js
@rspbot
Copy link

rspbot commented Feb 21, 2023

# Conflicts:
#	packages/@adobe/react-spectrum/package.json
#	packages/@react-spectrum/actionbar/docs/ActionBar.mdx
@rspbot
Copy link

rspbot commented Feb 28, 2023

@rspbot
Copy link

rspbot commented Feb 28, 2023

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, verified locally that running make check-examples was catching typescript issues in the docs. Spot checked a couple of the docs changes and verified that they rendered just fine in the docs.

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, also spot checked the docs

@rspbot
Copy link

rspbot commented Mar 2, 2023

@rspbot
Copy link

rspbot commented Mar 2, 2023

## API Changes

unknown top level export { type: 'identifier', name: 'Column' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }

@devongovett devongovett merged commit 9eb8796 into main Mar 2, 2023
@devongovett devongovett deleted the docs-ts branch March 2, 2023 22:24
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.

6 participants