From 6e1536930e11020281d34310b6fca726cf87968f Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Tue, 17 Aug 2021 22:30:49 -0500 Subject: [PATCH] Made setupFeatures use more accurate types --- src/game/layers.ts | 41 ++++++++++++++++++++--------------------- src/typings/layer.d.ts | 4 ++-- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/game/layers.ts b/src/game/layers.ts index c4c9783..ccf4292 100644 --- a/src/game/layers.ts +++ b/src/game/layers.ts @@ -92,11 +92,10 @@ export function addLayer(layer: RawLayer, player?: Partial): void { } } if (layer.upgrades) { - setupFeatures< - RawGridFeatures, Upgrade>, - GridFeatures, - Upgrade - >(layer.id, layer.upgrades); + setupFeatures, NonNullable, Upgrade>( + layer.id, + layer.upgrades + ); setRowCol(layer.upgrades); for (const id in layer.upgrades.data) { layer.upgrades.data[id].bought = function() { @@ -190,8 +189,8 @@ export function addLayer(layer: RawLayer, player?: Partial): void { } if (layer.achievements) { setupFeatures< - RawGridFeatures, Achievement>, - GridFeatures, + NonNullable, + NonNullable, Achievement >(layer.id, layer.achievements); setRowCol(layer.achievements); @@ -209,8 +208,8 @@ export function addLayer(layer: RawLayer, player?: Partial): void { } if (layer.challenges) { setupFeatures< - RawGridFeatures, Challenge>, - GridFeatures, + NonNullable, + NonNullable, Challenge >(layer.id, layer.challenges); setRowCol(layer.challenges); @@ -301,11 +300,10 @@ export function addLayer(layer: RawLayer, player?: Partial): void { } } if (layer.buyables) { - setupFeatures< - RawGridFeatures, Buyable>, - GridFeatures, - Buyable - >(layer.id, layer.buyables); + setupFeatures, NonNullable, Buyable>( + layer.id, + layer.buyables + ); setRowCol(layer.buyables); setDefault(layer.buyables, "respec", undefined, false); setDefault( @@ -353,8 +351,8 @@ export function addLayer(layer: RawLayer, player?: Partial): void { } if (layer.clickables) { setupFeatures< - RawGridFeatures, Clickable>, - GridFeatures, + NonNullable, + NonNullable, Clickable >(layer.id, layer.clickables); setRowCol(layer.clickables); @@ -375,10 +373,11 @@ export function addLayer(layer: RawLayer, player?: Partial): void { } } if (layer.milestones) { - setupFeatures, Milestone>, Features, Milestone>( - layer.id, - layer.milestones - ); + setupFeatures< + NonNullable, + NonNullable, + Milestone + >(layer.id, layer.milestones); for (const id in layer.milestones.data) { layer.milestones.data[id].earned = function() { return ( @@ -416,7 +415,7 @@ export function addLayer(layer: RawLayer, player?: Partial): void { } } if (layer.grids) { - setupFeatures, Grid>, Features, Grid>( + setupFeatures, NonNullable, Grid>( layer.id, layer.grids ); diff --git a/src/typings/layer.d.ts b/src/typings/layer.d.ts index a03bd14..9059174 100644 --- a/src/typings/layer.d.ts +++ b/src/typings/layer.d.ts @@ -37,7 +37,7 @@ export interface RawLayer extends RawFeature { subtabs?: Record>; microtabs?: Record; upgrades?: RawGridFeatures, Upgrade>; - startData?: () => Record; + startData?: () => Record; } export interface Layer extends Feature { @@ -115,7 +115,7 @@ export interface Layer extends Feature { activeSubtab?: Subtab | undefined; microtabs?: Record; upgrades?: GridFeatures; - startData?: () => Record; + startData?: () => Record; click?: () => void; automate?: () => void; reset: (force?: boolean) => void;