-
Notifications
You must be signed in to change notification settings - Fork 37
Fix TypeScript errors in lib/utils #231
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
base: ts-fixes
Are you sure you want to change the base?
Conversation
23a250c
to
39e9c1f
Compare
const unpaddable = ['scaleThreshold', 'scaleQuantile', 'scaleQuantize', 'scaleSequentialQuantile']; | ||
|
||
/** | ||
* @typedef {import('d3-scale').ScaleLinear<any, any> | |
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.
Here I went through the d3-docs and added the interface definitions.
Not sure whether one should exclude those that are filtered out with unpaddable
or whether there is already combinations like scaleContinuousNumeric
which would make the list shorter.
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 think, even though the script will handle an unpaddable scale, that it should be a typescript error if you try to pass in an unpaddable scale.
I didn't follow the second part of what you were saying about scaleContinuous Numeric
. Can you explain what you mean more?
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.
Sorry I should have linked that. in d3-typed there is scaleContinousNumeric, which then gets extended to ScaleLinear
, ScalePower
, ScaleLogarithmic
and a few more.
Thanks for this one. I was away for a few weeks and will go through this. |
I think this is looking really good. I made some changes and added some comments. I still need to go through |
src/lib/utils/padScale.js
Outdated
@param {Function} scale A D3 scale funcion | ||
@param {number[]} padding A two-value array of numbers specifying padding in pixels | ||
@param {Scale} scale A D3 scale funcion | ||
@param {[number, number]} padding A two-value array of numbers specifying padding in pixels | ||
@returns {number[]} The padded domain |
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 return type is [number, number]
also, right?
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.
Yes, I think so! :)
I hadn't had a chance to work on Layer Cake projects for a while, but now I was working on one and am motivated to finish this! Happy to simplify this into multiple PRs, if there is some stuff that still needs more thinking and sorry for the long delay! |
I think keeping it in one PR is okay. I think I needed to still go through some of the files, too. I've been spending a lot of time on a layercake-adjacent project but the positive part of that is I have been using types a lot more. I appreciate your help in working on this more! |
This fixes a few more TypeScript errors, those in
lib/utils
(see #218).The error messages were: