-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: add typescript typings #10287
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
feat: add typescript typings #10287
Conversation
Codecov Report
@@ Coverage Diff @@
## master #10287 +/- ##
==========================================
- Coverage 96.27% 96.27% -0.01%
==========================================
Files 68 68
Lines 9772 9763 -9
==========================================
- Hits 9408 9399 -9
Misses 364 364
Continue to review full report at Codecov.
|
|
Is this ready or still under WIP @SimonSchick ? |
|
@sushantdhiman I was hoping for some feedback, I highly doubt that this PR is ready as is. I'm not exactly sure what to add in terms of documentation. |
|
Unfortunately I'm not using sequelize at the current project I'm working on and the last one is with outdated typescript version. Saying this it is really difficult for me to test the PR. Anyway the definition file for sequelize is somehow a different program ( e.g. Thanks guys for adding the definition files to the project. 👍 |
|
@SimonSchick I can try to find some time to put this PR through its paces, but I doubt it'll be comprehensive. It may be worth creating a test file like the one we use in the DT repo to validate that the typings conform to the API as you believe they should. I can help get the ball rolling on that if you're interested. |
|
Link to the DT test file: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/sequelize/sequelize-tests.ts Moment did something similar after an errant typo broke their declaration files: |
|
@todd I already added test files? |
|
@SimonSchick Oh, yikes - I clearly didn't do a deep dive on the changes in this PR 😆 If the tests pass, I assume that's probably good enough to get started, at least for pre-5.0. But, again, I'll try to put the code in this PR through its paces in the next couple of days and see if I run across anything. From a purely pragmatic standpoint, I might recommend contributing these changes to Types or DT for 5.0 before adding them directly to this package. Not sure if we're worried about churn, but the DT declaration files see somewhat consistent changes and updates (maybe ~2-3 PRs/month on average). Totally up to you guys, though. |
|
I would love to have these definitions inside of the primary repo. I find they stay in sync easier that way. Thanks for starting this! @SimonSchick Was wondering why you removed the Also, I'll try and take a look at these this weekend also. Looking to use v5 in my next project anyway. |
|
sliceArgs slipped into this PR, if that's an issue I will revert that. |
|
Removed WIP tag for now, I have not really gotten any feedback but I've been using these typings in a few projects and they seem pretty stable. |
| }); | ||
|
|
||
| sequelize | ||
| .query('INSERT into test set test=1', { |
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.
the indentation looks ugly here 😉
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'd add linting for TS but I don't want to bloat up the CI.
|
We can improve typings after it ships to the npm prerelease or release, integrating with real projects. |
sushantdhiman
left a comment
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.
Going to merge this @SimonSchick , once these get deployed community can improve them.
|
@SimonSchick Great work 💯 |
|
Oh boy. |
|
I wonder if we can somehow generate the api docs from typescript typings, or typescript typings from jsdoc? It seems kinda of stupid to keep two different forms of api docs in the code |
|
I've seen this happen with puppeteer/puppeteer#3744 but I strongly suggest against it, not only will it add a build step but will also be much less flexible than raw typings. Generating the docs from typing files seems like a much better approach Ideally we would just move sequelize to TS entirely, this would give all benefits. I believe the counter arguments were:
But obviously that's a stupid amount of work :) |
Yeah that sounds more reasonable to me as well - Do you have any examples of projects doing it this way?
I don't have any specific count arguments to this, other than the amount of work required I see that all they typings are now stored in separate files - Is there no way to store them "closer" to the code - I feel like it would be easier to make sure that typings are kept in check with the actual code if they are located closely together, so that when you add a new argument to a method, you remember to add it to the typings as well. Perhaps we should add "update typings" to the PR checklist @sushantdhiman ? |
|
Also, great work! :) 🎉 |
|
While an old PR, was there a guide somewhere to help folks migrate from the 4.28 "definitelytyped" definitions to the native v5 ones? (particularly problematic with old codebases that are several versions behind at this point but still need uplifting). Some things are easy to rewrite, but others are a puzzle that no amount of Google or Stackoverflow seems to explain (like what to do with code that relied on |
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
Closes #9285
TODO: Documentation?
Please note that these typings are based on https://github.com/types/sequelize but have been heavily modified and updated for v5 use by me.
These typings are generally not compatible with the current DT typings as they are considered incomplete and outdated (no class support etc).
I'd ask like to ask types/sequelize contributors:
@felixfbecker
@louy
@eseliger
@ppetzold
@prokopsimek
@lumaxis
@C45tr0
@d6u
@modulitos
@rokoroku
@MorpheusXAUT
@SwadicalRag
@JD-Robbs
@munsellj
@Thylossus
And DT contributors:
@samuelneff
@CodeAnimal
@drinchev
@babolivier
@kukoo1
@oktapodia
@MorpheusXAUT
@TitaneBoy
@zjy01
@nidzov
@Raigen
@todd
@nrschultz
@Thomas-B
@Antoine38660
@smff
to leave feedback on this PR
@felixfbecker @louy as you are core authors of
types/sequelize, do you have any concerns regarding the licensing?Currently your
package.jsononly specifiesISCwithout a license file which is generally compatible with theMITlicense of sequelize.