-
-
Notifications
You must be signed in to change notification settings - Fork 2k
build: Enable TypeScript type checking #7680
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: master
Are you sure you want to change the base?
Conversation
…escript-type-checking
| 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.
Choose a reason for 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?
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.
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.
| 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.
Choose a reason for 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?
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, 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;
...,
}| * Use specific trace types when available | ||
| */ | ||
| export interface GenericTrace extends TraceBase { | ||
| x?: 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.
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.
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.
That's why it's permissive here. Once we become sure, we can change this as you suggest.
Description
Enable TypeScript type checking.
Closes #7678.
Changes
Testing
npm run buildlocally to check that everything is bundled properly by esbuildnpm run typecheckto perform a type check on the source code. There should be no errors:Notes
npm run typecheck. VS Code will also provide feedback as you're editing files.