-
Notifications
You must be signed in to change notification settings - Fork 276
Open
Description
Description
Currently when defining explicitly defining an object of type Options
with columns
and passing it to parse
, the TypeScript compiler will complain:
const options: Options<RowType> = {
onRecord: this.filterRow.bind(this),
columns: ["a", "b", "c"],
}
const result = parse(content, options)
Type error is:
Argument of type Options<AgentRow> is not assignable to parameter of type OptionsWithColumns<AgentRow>
The reason is that a non-string declaration of parse
expects OptionsWithColumns
.
Proposed solution
The only way it works without exposing the type is to inline the options, but likely not everybody wants to do that, so exporting OptionsWithColumns
would be great so they can simply be used as the type.
// Same definition as from library
type OptionsWithColumns<T> = Omit<Options<T>, "columns"> & {
columns: Exclude<Options["columns"], undefined | false>;
};
// Defining options with this will work
const options: OptionsWithColumns<RowType> = {
onRecord: (a) => a,
columns: ["a", "b", "c"]
}
const result = parse(content, options)
Metadata
Metadata
Assignees
Labels
No labels