-
Notifications
You must be signed in to change notification settings - Fork 470
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
Copied types from DefinitelyTyped into this repository #530
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 430236e:
|
Codecov Report
@@ Coverage Diff @@
## master #530 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 23 23
Lines 438 438
Branches 105 105
=========================================
Hits 438 438 Continue to review full report at Codecov.
|
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.
Awesome, thank you for this!
Is there any way we can add something to the validate
script that will check these typings are correct? I've had some projects where they'll have a set of TypeScript files in the project and run the typings against those files to make sure they pass type checking.
@kentcdodds Would you be open to adding type annotations via JSDOC? We could generate the declarations directly from the source files while simultaneously checking that the types are correct (and actually type check the source files). That way we keep any TypeScript syntax out and the current workflow doesn't change. At least I think this is possible. The typings are simple enough that JSDOC should be sufficient. |
I think that would be a good iterative approach to migrating to TypeScript (if that's what we end up doing). I'd be willing to take a look at that, yeah. |
Sure, I think DefinitelyTyped also runs some sort of tests on their types, I'll investigate and add something |
I've added the type tests like DefinitelyTyped does it, I commited in a way that you can see the tests fail, before adjustments are made. If you change the type-tests.ts in a way that types don't make sense (as in it doesn't compile anymore) the npm verify step will now fail. I honestly don't think it's too much work to port this code base to TypeScript, I personally wouldn't add any more intermediate steps. |
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.
Looks good to me with one minor nit.
Just need to decide in which version we want to drop this.
The jsdoc + js-check effort can be made in another PR with the goal of keeping the types in sync.
I might give it a shot to port the code base to TypeScript - should I wait out on that? |
For now we don't want to use actual TypeScript. After we resolved this PR I'm going to try out types via JSDOC. |
@@ -0,0 +1,8 @@ | |||
export function waitForElementToBeRemoved<T>( |
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.
Fyi, I made a PR to DefinitelyTyped to add the interval
option here.
It got merged today, so I believe we should also add it here.
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/44006/files
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.
actually since options is simply passed to waitFor, it should just use the same type, so we don't have to redefine it in multiple places, I'll take care of it
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.
That's a good idea 👍
Regarding JSDOC: It doesn't seem like we can incorporate TS types at the moment. I wouldn't know how to type |
Ok, I'm thinking this is a good idea. Shame about the JSDOC stuff. Let's go ahead and get this merged and then we can explore migrating to TS totally. Looks like there's a conflict in the package.json (sorry, my bad). I just released a major version to kcd-scripts which now will automatically run a |
Sorry, clicked the wrong button. Also sorry about that, I mistakenly removed Go ahead and rebase again if you please and make sure to re-install deps. Thanks! |
Sure! Will hopefully run through now - does merging this PR count as a 'migrate to TS pull request is welcome'? :-D |
A pull request would be welcome, but I'm not certain that it would be merged. To be frank, I'm insecure about my personal TypeScript abilities (just haven't had enough time with it honestly) so I've been hesitant to add TS to my projects primarily for that reason (though the barrier to contributions is also a consideration). So I'm willing to take a look and provide feedback on a PR, but I'm not 100% certain that it would get merged. |
Is there anything left on this PR? I want to leave this open for a day or two more to make sure everyone who's got an opinion shares it. Merging this PR means that every API change should be associated with updates to the TypeScript definitions, so it has important implications. |
Fair enough. From my point of view, this PR is complete. |
Ok, let's do this. |
🎉 This PR is included in version 7.5.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
I use
Looks like you need to use relative paths. |
@kentcdodds I've opened a PR to try to fix the above: #556 |
@kentcdodds could you also add me as a contributor? |
@all-contributors add @Lagily for code |
I've put up a pull request to add @Lagily! 🎉 |
What: Copied types from DefinitelyTyped into this repository and adjusted the package.json, so these types are packed into the npm package. Also removed the dependency to the DefinitelyTyped types, since they are now in this repo.
Why: See #494 (comment)
Checklist:
docs site
DefinitelyTyped
Not sure as to where and how you would like documentation to be added. I don't think additional documentation is needed (yet). We should instead make a PR to remove dom-testing-library from DefinitelyTyped - what do you think?