fix the types

This commit is contained in:
J H
2024-01-30 16:28:40 -07:00
parent cbded5f4e9
commit 01ad2421b4
8 changed files with 24 additions and 50 deletions

View File

@@ -42,12 +42,12 @@ export class Backups<M extends SDKManifest> {
private constructor(
private options = DEFAULT_OPTIONS,
private backupSet = [] as BackupSet<keyof M["volumes"] & string>[],
private backupSet = [] as BackupSet<M["volumes"][0]>[],
) {}
static volumes<M extends SDKManifest = never>(
...volumeNames: Array<keyof M["volumes"] & string>
) {
return new Backups().addSets(
...volumeNames: Array<M["volumes"][0]>
): Backups<M> {
return new Backups<M>().addSets(
...volumeNames.map((srcVolume) => ({
srcVolume,
srcPath: "./",
@@ -57,7 +57,7 @@ export class Backups<M extends SDKManifest> {
)
}
static addSets<M extends SDKManifest = never>(
...options: BackupSet<keyof M["volumes"] & string>[]
...options: BackupSet<M["volumes"][0]>[]
) {
return new Backups().addSets(...options)
}
@@ -75,7 +75,7 @@ export class Backups<M extends SDKManifest> {
}
return this
}
volumes(...volumeNames: Array<keyof M["volumes"] & string>) {
volumes(...volumeNames: Array<M["volumes"][0]>) {
return this.addSets(
...volumeNames.map((srcVolume) => ({
srcVolume,
@@ -85,7 +85,7 @@ export class Backups<M extends SDKManifest> {
})),
)
}
addSets(...options: BackupSet<keyof M["volumes"] & string>[]) {
addSets(...options: BackupSet<M["volumes"][0]>[]) {
options.forEach((x) =>
this.backupSet.push({ ...x, options: { ...this.options, ...x.options } }),
)

View File

@@ -4,14 +4,14 @@ import { ExpectedExports } from "../types"
import { _ } from "../util"
export type SetupBackupsParams<M extends SDKManifest> = Array<
(keyof M["volumes"] & string) | Backups<M>
M["volumes"][0] | Backups<M>
>
export function setupBackups<M extends SDKManifest>(
...args: _<SetupBackupsParams<M>>
) {
const backups = Array<Backups<M>>()
const volumes = new Set<keyof M["volumes"] & string>()
const volumes = new Set<M["volumes"][0]>()
for (const arg of args) {
if (arg instanceof Backups) {
backups.push(arg)