| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| var constants = require('./constants'); | ||
| var overrideAll = require('../../plot_api/edit_types').overrideAll; | ||
| var sortObjectKeys = require('../../lib/sort_object_keys'); | ||
| var sortObjectKeys = require('../../lib/sort_object_keys').default; |
There was a problem hiding this comment.
@camdecoster Is it worth considering moving away from default exports entirely as part of this transition?
Sorry, something went wrong.
There was a problem hiding this comment.
It only matters when one mixes CJS and ESM. That said, I don't think that we can avoid that for a long time. I suppose we could make just pick a direction to go and standardize. I could go either way, but the esbuild docs make it clear that they don't like default exports.
Sorry, something went wrong.
Sorry, something went wrong.
| fillcolor?: string; | ||
| line?: Partial<Line>; | ||
| marker?: Partial<Marker>; | ||
| mode?: 'lines' | 'markers' | 'lines+markers' | 'none' | 'text' | 'lines+text' | 'markers+text' | 'lines+markers+text'; |
There was a problem hiding this comment.
Does TypeScript have any support for 'flag list'-type string values such as this, where the string may consist of any number of a fixed set of values joined by a delimiter? I suppose not as it's fairly custom.
Otherwise could we use a custom type or a custom function to generate these lists of allowed values based on the flags?
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, it's called a union type. What's shown on 133 is an example of that (though it's only used on that line). If we needed that type elsewhere, we could define it separately and reference it within the ScatterTrace type like this:
type Mode = 'lines' | 'markers' | 'lines+markers' | 'none' | 'text' | 'lines+text' | 'markers+text' | 'lines+markers+text';
export interface ScatterTrace extends TraceBase {
...,
mode: Mode;
...,
}
Sorry, something went wrong.
There was a problem hiding this comment.
Yeah I guess I'm imagining something like a helper function which looks like flagList(flaglistVals, otherVals) such that
flaglistVals(['lines', 'markers', 'text'], ['none'])
returns
'lines' | 'markers' | 'lines+markers' | 'none' | 'text' | 'lines+text' | 'markers+text' | 'lines+markers+text';`
Sorry, something went wrong.
| * Use specific trace types when available | ||
| */ | ||
| export interface GenericTrace extends TraceBase { | ||
| x?: any[]; |
There was a problem hiding this comment.
I'm not sure there are any traces where x/y/z are allowed to be a type other than number[] | string[] but I could be wrong about that.
Sorry, something went wrong.
There was a problem hiding this comment.
That's why it's permissive here. Once we become sure, we can change this as you suggest.
Sorry, something went wrong.
There was a problem hiding this comment.
In this case maybe it would be easier to start stricter and loosen if needed?
Sorry, something went wrong.
There was a problem hiding this comment.
Actually, scratch that
Sorry, something went wrong.
|
@camdecoster Can you add a type-check step to the CI? |
Sorry, something went wrong.
| yaxis?: Partial<LayoutAxis>; | ||
|
|
||
| // Multiple axes support (xaxis2, yaxis3, etc.) | ||
| [key: string]: any; |
There was a problem hiding this comment.
Can we tighten this layout spec here to match the plot schema?
Sorry, something went wrong.
|
@camdecoster Some initial thoughts on organization of the types: For types corresponding directly to the schema:
|
Sorry, something went wrong.
There was a problem hiding this comment.
Great work! The implementation is clean and easy to understand
Sorry, something went wrong.
| "declaration": false, | ||
| "declarationMap": false, | ||
| "sourceMap": true, | ||
| "outDir": "./dist", |
There was a problem hiding this comment.
Is this needed if there's no output?
Sorry, something went wrong.
There was a problem hiding this comment.
Oh never mind, I guess this config file is used by esbuild as well?
Sorry, something went wrong.
There was a problem hiding this comment.
It is used by esbuild, but there are some options (including this one) that don't get used. I'll remove them.
Sorry, something went wrong.
| } | ||
|
|
||
| // PlotType — derived from the list of trace names, not from an attribute. | ||
| found.set('PlotType', { values: Object.keys(schema.traces).sort() }); |
There was a problem hiding this comment.
This really should be called TraceType... the question is, is it worth breaking correspondence with DefinitelyTyped to use the semantically correct type name?
Sorry, something went wrong.
There was a problem hiding this comment.
I think we can do whatever we want. I'm less interested in maintaining the DT API since I started using the schema as the source of truth. I'll look into the possibility of changing the name.
Sorry, something went wrong.
|
@camdecoster I think it would be useful to add guidance for converting non-attributes files as well, or at least guidance on which files are the highest-priority to convert and which ones don't need to be touched. But again that doesn't need to be blocking for merge. |
Sorry, something went wrong.
There was a problem hiding this comment.
Left a bunch of nitpicky comments but big picture LGTM.
Sorry, something went wrong.
Co-authored-by: Emily KL <4672118+emilykl@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Description
Enable TypeScript type checking.
Part of #7678.
Changes
Testing
Notes