Skip to content

Stricter type check for type definition #278

@NattapongSiri

Description

@NattapongSiri

Is your feature request related to a problem? Please describe.

A type definition can be stricter so that parse have more type hint in typescript.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
In csv-parse

  1. onRecord should return type conform to expected type,
  2. parse data callback should have signature of (err, data) => {} where data should be of the same type defined in onRecord return type.
  3. columns should have keyof type of expected type in list or a function that return keyof of expected type in list
  4. Parser class should extends AsyncIterator so the for await syntax can infer type.

Describe the solution you'd like
Use generic in type declaration. To prevent breaking change, specify any as default of generic.

A clear and concise description of what you want to happen.
Many type checker should be applicable in compile time type checking. Using mechanism available in typescript can aid this aspect. Instead of relying on always any type everywhere, using generic with default to any can be useful if developer choose to opt-in.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.
None

Additional context

Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions