plot
plot copied to clipboard
ts options
Typescript for data (the expected shapes of data) and options (valueof, arrayify), with tooling and unit tests.
Was researched initially in #1008, and confirmed to work with all the transforms and more in #1005.
Thanks for testing this Michael! Here are a few cases that seem to work for me.

However I don't have autocompletion on the empty string, which I think used to work in an earlier stage 😅
A related error is that the popup here says that the value is null | undefined, when it will actually be an array of undefined
@@ -16,7 +16,8 @@ export type Row = Record<string, Value>;
*/
export type Datum = Row | Value | Value[];
export type FieldNames<T> = T extends Row
- ? keyof T
+ ? // eslint-disable-next-line @typescript-eslint/ban-types
+ keyof T | (string & {})
: T extends Value[]
? // eslint-disable-next-line @typescript-eslint/ban-types
"length" | "0" | "1" | "2" | (string & {})
With this patch, we get autocomplete to work again, and the issue or "wrongfully giving undefined | null" above goes away too. However the price to pay is that we lose the ts error on:
valueof([{one: "one", two: "two"}], "red");
I think this makes sense.
I hope we can restart work on this soon, with a simpler approach (not trying to pass the shape of data through all the code).
Probably superseded by #1320 which goes the d.ts route, but would be nice to repurpose the type tests here?
l33t tests at #1337