-
Notifications
You must be signed in to change notification settings - Fork 528
Typescript: Generate proper .d.ts files for Core #2271
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
Conversation
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 - these type files are much more manageable when we move them into their respective directories. Do you anticipate any problems with us releasing this as a patch version bump? In other words, moving these types around won't change anything for users importing types from Victory, correct?
The main difference right now is that we're not exporting * yet. So the props are not yet being exported. I've fixed this already in the next PR, #2274 |
What
.d.ts
output for our builds.tsconfig.json
for each package (which just extends the base config). This is necessary to set the proper "scope" for each build ... otherwise TypeScript will always compile everything.Migration Pattern
Currently, each package has a top-level
index.d.ts
file, which contains type definitions for all exported members.This is problematic, because when a method signature changes, the type definition must be updated manually.
The best, but hardest, solution is to convert all
.js
files to.ts
. While we do anticipate this being the "end game" for us, it's a lot of work to handle at once.Instead, here's a way to migrate in steps:
index.d.ts
contents into separate files.For example, I split the
victory-core/src/index.d.ts
file into a bunch of files, likevictory-accessible-group.d.ts
,victory-animation.d.ts
,victory-label.d.ts
and so on. I moved those files into the matching folder, alongside the matching.js
file.index.d.ts
fileindex.js
toindex.ts
. This usually doesn't require any changes.That's it! When we create our builds, all our
.d.ts
files will be copied to the output. Also, all.ts
files will be compiled, and the generated.d.ts
files will be in the output as well; especially theindex.d.ts
.Testing
Build everything via:
.d.ts
files, like:index.d.ts
should be the same as theindex.ts
, just a bunch of exports, like: