From 94db0f0988ce73c71761fdaa8ae02c6facb3faaa Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Fri, 12 Jun 2020 02:28:16 -0700
Subject: [PATCH] Use an object literal instead of a map because apparently
 that makes Typescript type inference work *way* better.

---
 src/Mods/SecExp/js/Unit.js | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/Mods/SecExp/js/Unit.js b/src/Mods/SecExp/js/Unit.js
index d789999c0f3..36c0c413185 100644
--- a/src/Mods/SecExp/js/Unit.js
+++ b/src/Mods/SecExp/js/Unit.js
@@ -84,29 +84,26 @@ App.SecExp.trainingValueToBonusFactor = function(value) {
 };
 
 App.SecExp.getEdictUpgradeVal = (function() {
-	/** @typedef {Map<string, {defense?: number, attack?: number, morale?: number, hp?: number}>} EdictMap */
-	/** @type {Map<string, EdictMap>} */
-	const data = new Map([
-		["Militia", new Map([
+	const data = {
+		Militia: new Map([
 			["legionTradition", {defense: 2, morale: 5, hp: 1}],
 			["pharaonTradition", {attack: 2, defense: 2, morale: 10}],
 			["sunTzu", {attack: 1, defense: 1, morale: 5}],
 			["eliteOfficers", {morale: 5}],
 			["lowerRequirements", {defense: -1, hp: -1}]
-		])],
-		["Slave", new Map([
+		]),
+		Slave: new Map([
 			["mamluks", {attack: 2, morale: 10, hp: 1}],
 			["sunTzu", {attack: 1, defense: 1, morale: 5}],
 			["eliteOfficers", {morale: -5}],
 			["martialSchool", {morale: 5}]
-		])],
-		["Merc", new Map([
+		]),
+		Merc: new Map([
 			["eagleWarriors", {attack: 4, defense: -2, morale: 10}],
 			["ronin", {attack: 2, defense: 2, morale: 10}],
 			["sunTzu", {attack: 1, defense: 1, morale: 5}],
-		])],
-		["Dummy", new Map([ ["", {} ] ])] // this bastard SOMEHOW makes Typescript happy...
-	]);
+		])
+	};
 
 	/** Get the total edict upgrade effect on a particular stat for a particular unit
 	 * @param {string} unitType
@@ -115,8 +112,7 @@ App.SecExp.getEdictUpgradeVal = (function() {
 	 */
 	function getNetEffect(unitType, stat) {
 		let retval = 0;
-		const unitMap = data.get(unitType);
-		for (const [key, val] of unitMap) {
+		for (const [key, val] of data[unitType]) {
 			if (V[key] > 0 && val[stat]) {
 				retval += val[stat];
 			}
-- 
GitLab