Skip to content

Export for type OptionsWithColumns is missing #464

@maxdev1

Description

@maxdev1

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions