-
Notifications
You must be signed in to change notification settings - Fork 561
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
Add TS types for component-component, dialog, portal, rect, alert-dialog, and utils. #105
Conversation
3496c75
to
4408646
Compare
One thing that caught my eye is using I as the prefix of every interface name. In my opinion it's unnecessary. Also, as I remember correctly, none of already defined typings use this convention 🙂 I will look more into it when I will have access to my computer. |
Ahh yeah I'll take them out! I'm about to make another pass over everything and fix a couple of things. |
Awesome 👍 |
pushed up a couple of changes. there are a few things im not sure about that i was going to leave some discussions on. |
Removed the RFC and WIP tags from this. It's ready for review. |
@hedgerh Can you submit these to Definitely Typed? |
@ecoleman once they get reviewed, im hoping they will just get merged in here so that they wont need to be published to Definitely Typed, but im open to it. im going to pull them back down and test them to see if they're good. i am hoping someone who is more adept with Typescript can give them a look over. |
f2ab411
to
9f7f133
Compare
f265ece
to
e4a0a4e
Compare
I just copied the Tabs typedefs to my project to test it out, and ran into a few bugs:
|
Hey hey, I'll make the updates real quick. I pulled those in from someone else who had typed them. I'm not really sure what to do with this MR. It's been sitting in limbo forever. |
@johnridesabike after reviewing the types that are on my branch, it appears that export interface BaseTabProps<A> {
children?: React.ReactNode;
as?: ComponentType;
rest?: A;
}
export interface TabProps<A = React.HTMLAttributes<HTMLDivElement>>
extends BaseTabProps<A> {
disabled?: boolean;
} As for |
@hedgerh I think you're right about the children. I don't know why that popped up for me... maybe I was still using the other typedefs I copied?
|
hi @hedgerh thanks for posting your types just wanna add that @reach/rect should also export this: export function useRect(rect: Ref, isSelected?: boolean): IClientRect i also use declare module "@reach/rect" {
import { Ref } from "react"
export interface Rect {
x: number
y: number
width: number
height: number
top: number
right: number
bottom: number
left: number
}
type RectProps = {
observe?: boolean
onChange?: (rect: Rect) => void
children?: React.ReactNode
}
const Rect: React.SFC<RectProps>
export default Rect
export function useRect(rect: Ref, isSelected?: boolean): Rect
} |
import { ComponentType, StyleHTMLAttributes } from "react"
export interface BaseTabProps<A> {
children?: React.ReactNode
as?: ComponentType
rest?: A
style?: StyleHTMLAttributes // missing from hedgerh
} |
hey @sw-yx, thanks for the callouts. Is BaseTabProps even typed right at all? |
Co-Authored-By: hedgerh <hedgerh@gmail.com>
195f6f6
to
4deb240
Compare
actually was able to check myself and, yep, it wasn't typed right. fixed it, so className and style should work now. @ryanflorence any chance you could signal boost or something to get someone to review and 👍 this? just realized this PR has been open for 3 months. you all are lovely, but I want to be freeeee |
I just tested the new tab typedefs in my project and it all seems to be good. Hopefully this can get reviewed/approved soon! |
const Rect: React.FC<RectProps> | ||
|
||
export default Rect | ||
export function useRect(rect: Ref, isSelected?: boolean): ClientRect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just working on some typedefs for rect
as well and I noticed that this will return null on the first render before the elements are in the DOM. Awesome work!
@@ -0,0 +1,24 @@ | |||
declare module "@reach/rect" { | |||
import { Ref } from "react" | |||
interface ClientRect { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another little thing I noticed is that there's a type definition built in for DOMRect
which you could use here instead of re-defining it. Here's a link to the DOMRect definition. You should be able to use it here by adding /// <reference lib="dom"/>
to the top of this definition file. Here's a link to the triple slash documentation
@Dhalton Nice. I'll add that in. Just want to let everyone know that I'm moving these types over to DefinitelyTyped right now. Ryan doesn't really want to deal with them until the library matures a bit. I'll share the MRs for the work when they're ready, and they should be ushered through by maintainers of DT. |
You're the bomb, @hedgerh ! Was afraid I'd have to write these up myself, thanks for sharing. |
For anyone following this PR and not the reach ui types issue, I just completed writing some typedefs to publish to DefinitelyTyped. They are now in review. Can follow here #37 (comment) |
Closing this PR for now, but as mentioned in #37 I am going to work on getting all types worked into the project over the coming weeks. Thanks everyone for your contributions here and on Definitely Typed! |
Update - All typedefs are being published to DefinitelyTyped. Read on:
To install them, you have to use a special syntax. For example:
yarn add @types/reach__menu-button
yarn add @types/reach__alert-dialog
yarn add @types/reach__tabs
etc.
Some have been published, some are in review. Follow along here - #37 (comment)