GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — build: Enable TypeScript type checking by camdecoster · Pull Request #7680 · plotly/plotly.js Conversation
|
| 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.
The reason will be displayed to describe this comment to others. Learn more.
@camdecoster Is it worth considering moving away from default exports entirely as part of this transition?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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.
The reason will be displayed to describe this comment to others. Learn more.
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 an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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 an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
There was an error while loading. Please reload this page.
| * Use specific trace types when available | ||
| */ | ||
| export interface GenericTrace extends TraceBase { | ||
| x?: any[]; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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 an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That's why it's permissive here. Once we become sure, we can change this as you suggest.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In this case maybe it would be easier to start stricter and loosen if needed?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actually, scratch that
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@camdecoster Can you add a type-check step to the CI? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| yaxis?: Partial<LayoutAxis>; | ||
|
|
||
| // Multiple axes support (xaxis2, yaxis3, etc.) | ||
| [key: string]: any; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we tighten this layout spec here to match the plot schema?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@camdecoster Some initial thoughts on organization of the types: For types corresponding directly to the schema:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Great work! The implementation is clean and easy to understand
Sorry, something went wrong.
There was an error while loading. Please reload this page.
2439dad to
de168ca
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| "declaration": false, | ||
| "declarationMap": false, | ||
| "sourceMap": true, | ||
| "outDir": "./dist", |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is this needed if there's no output?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Oh never mind, I guess this config file is used by esbuild as well?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| // 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.
The reason will be displayed to describe this comment to others. Learn more.
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 an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
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.
There was an error while loading. Please reload this page.
|
@camdecoster I think it would be useful to add guidance for converting non- |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Left a bunch of nitpicky comments but big picture LGTM.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Emily KL <[email protected]>
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[FEATURE]: Add TypeScript type checking
There was an error while loading. Please reload this page.