Skip to content
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

Add init type #735

Closed
vitaly-t opened this issue Jun 21, 2020 · 1 comment
Closed

Add init type #735

vitaly-t opened this issue Jun 21, 2020 · 1 comment

Comments

@vitaly-t
Copy link
Owner

vitaly-t commented Jun 21, 2020

Consider refactoring value into a strict type:

readonly init: (value: any) => any;
@vitaly-t
Copy link
Owner Author

vitaly-t commented Jun 21, 2020

Implemented in 10.5.7.

And type ColumnSet now supports templating for the source in methods init and skip:

interface IMyType {
    val: number;
}

const cs = new pgp.helpers.ColumnSet<IMyType>([
  {
    name: 'my-col',
    init(c) {
        // c.source is now strongly-typed as IMyType
    },
    skip(c) {
        // c.source is now strongly-typed as IMyType
    }
  }
]);

And type Column has been extended in the same way, to support Column<IMyType>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant