1
Fork 0

Add A and B types to Migration.

This commit is contained in:
Bauke 2023-05-08 12:23:28 +02:00
parent b798e18a16
commit 7c95c574ce
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
5 changed files with 6 additions and 6 deletions

View File

@ -7,9 +7,9 @@
* The migrate function should take the data you pass through {@link migrate}
* and modify it to your needs.
*/
export type Migration<V> = {
export type Migration<V, A = any, B = any> = {
version: V;
migrate: (data: any) => Promise<unknown>;
migrate: (data: A) => Promise<B>;
};
/**

View File

@ -3,7 +3,7 @@ import test from 'ava';
import {migrate, Migration} from '../source/migration-helper.js';
test('migrate<Date>', async (t) => {
const migrations: Array<Migration<Date>> = [
const migrations: Array<Migration<Date, string, string>> = [
{
version: new Date('2022-01-01'),
migrate: async (data: string) => `${data} migrated`,

View File

@ -3,7 +3,7 @@ import test from 'ava';
import {migrate, Migration} from '../source/migration-helper.js';
test('migrate<number>', async (t) => {
const migrations: Array<Migration<number>> = [
const migrations: Array<Migration<number, string, string>> = [
{
version: 5,
migrate: async (data: string) => `${data} migrated`,

View File

@ -12,7 +12,7 @@ test('migrate<{custom: number}>', async (t) => {
};
const skip: SkipMigrationFn<Custom> = (a, b) => a.custom > b.custom;
const migrations: Array<Migration<Custom>> = [
const migrations: Array<Migration<Custom, string, string>> = [
{
version: {custom: 5},
migrate: async (data: string) => `${data} migrated`,

View File

@ -3,7 +3,7 @@ import test from 'ava';
import {migrate, Migration} from '../source/migration-helper.js';
test('migrate<string>', async (t) => {
const migrations: Array<Migration<string>> = [
const migrations: Array<Migration<string, string, string>> = [
{
version: '0.2.4',
migrate: async (data: string) => `${data} migrated`,