-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type definitions #37
Comments
I'm all for it, but we're going to need somebody dedicated to that, because I don't know typescript well enough to do it myself, or even review the work of others for it, and I'm not interested enough in typescript to learn it 😬(I know, I should be, and I would love it) |
Just to have better look at current state of type definitions for all packages:
|
You start on |
Could use some feedback on my |
Sorry to keep pinging this issue, but I went ahead and started all of the other remaining types. They are part of the same PR I linked above. |
declare module '@reach/tabs' {
import { ComponentType } from "react"
export interface BaseTabProps {
children?: React.ReactNode
as?: ComponentType
}
export interface TabsProps<A = React.HTMLAttributes<HTMLDivElement>> extends BaseTabProps & A {
children: React.ReactNode
defaultIndex?: number
index?: number
onChange?(index: number): void
}
export class Tabs extends React.Component<TabsProps> {}
export type TabListProps<A = React.HTMLAttributes<HTMLDivElement>> = BaseTabProps & A
export class TabList extends React.Component<TabListProps> {}
export type TabPanelsProps<A = React.HTMLAttributes<HTMLDivElement>> = BaseTabProps & A
export class TabPanels extends React.Component<TabPanelsProps> {}
export type TabPanelProps<A = React.HTMLAttributes<HTMLDivElement>> = BaseTabProps & A
export class TabPanel extends React.Component<TabPanelProps> {}
export interface TabProps<A = React.HTMLAttributes<HTMLDivElement>> extends BaseTabProps & A {
disabled?: boolean
}
export class Tab extends React.Component<TabProps> {}
} Here are the types for |
added the tabs types to my PR |
So I've tested out all of the typedefs I did in my PR #105 What's the next move? Should we just merge them and see how they work or what? Need a reviewer |
Edit 2: The typedefs in #105 don't support props like Edit 1: I just copied @SleeplessByte's code into my project and it seems to have fixed my problem. Original comment: I'm not using TypeScript, but I use Here's specific error that it gives me for
TS can infer types from JS files, so adding typedefs isn't necessarily the only option to fix it if TS is just inferring them incorrectly. |
To make sure the response to @johnridesabike's issue is covered here, @SleeplessByte, your typings are off, actually. I updated my MR to fix this and wanted to give you the heads up. You can see the updates in here https://github.com/reach/reach-ui/pull/105/files#diff-fdb0763bfdc448564282bcf2ac0d3e53R1 |
My typings were generated from the documentation and not the code :) @hedgerh thank you! I've not had this issue at all but yes you are correct :D |
@reach/tooltip: [redacted, use SleeplessByte’s below] |
@sw-yx this would have the same issue as my types above (before the edit). declare module "@reach/tooltip" {
export interface BaseTooltipProps {
children: React.ReactNode
label: React.ReactNode
ariaLabel?: string
}
export interface TooltipProps<A = React.HTMLAttributes<HTMLDivElement>> extends BaseTooltipProps & A {
children: React.ReactNode
}
export default class Tooltip extends React.Component<TooltipProps> {}
} |
You're all great, thanks for sharing your snippets <3 |
Hey all, just an update: I think Ryan would rather wait until the library is more mature before worrying about types, so I've begun submitting typedefs for each component to DefinitelyTyped. Looks like the ones for |
cool. will you update us when the others have been published too? is this also the defacto umbrella issue for typings? lets make it easily discoverable where each typing is. |
This seems to be the only one that is a broad typings issue. I could start a new one to track my progress on creating the @types, if people would like. We should probably also add some docs on where to get them. |
|
Hey y'all 👋 When work picks up again on this, I wonder if it makes sense to have the type definitions bundled inside of I've found that community provided types in DefinitelyTyped tend to lag behind the libraries they compliment, and that it might be easier to keep the types in sync if they are co-located. The TypeScript docs have some decent guidance on packaging them with your library, by including a |
Ah actually reading some of the previous comments and #105 I might be missing some context. I would still advocate for types packaged in the library, but in any case looking forward to seeing this work move forward! |
Whew, got all the typedefs together on DefinitelyTyped for the @reach packages. All of them but @reach/alert are in PR right now. combobox - DefinitelyTyped/DefinitelyTyped#36379 tabs - DefinitelyTyped/DefinitelyTyped#36378 tooltip - DefinitelyTyped/DefinitelyTyped#36374 auto-id, rect, skip-nav, visually-hidden, window-size, utils - DefinitelyTyped/DefinitelyTyped#36373 menu-button - DefinitelyTyped/DefinitelyTyped#36372 component - DefinitelyTyped/DefinitelyTyped#36371 alert-dialog/dialog - DefinitelyTyped/DefinitelyTyped#36369
You'll be able to get them by running |
seems to be closed, any updates? |
Hey all, thanks a ton for all the contributions and conversation! We are going to close this issue for now. I'm very likely to add types to all of our components over the next few weeks, but it's a pretty low priority at the moment. Types on DefinitelyTyped are in pretty good shape and fixes can be addressed there in the mean time. Feel free to continue the conversation here -- I may well reopen it after I get more pressing issues fixed and the backlog cleared out. I want to have everything typed as much as anyone. 😬 |
It would be great to get some TypeScript type definitions written for each component.
The text was updated successfully, but these errors were encountered: