From 4be738fe4f600c6166271e32467620ab94bb9dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Tue, 2 May 2017 23:33:58 +0200 Subject: [PATCH] Updated to typescript 2.3 --- .vscode/settings.json | 1 - package.json | 4 ++-- src/MainUI.spec.ts | 2 +- src/common | 2 +- src/core/Equipment.ts | 6 +++--- src/core/LootGenerator.ts | 9 +++++---- src/core/Ship.ts | 2 +- src/core/ai/TacticalAI.ts | 2 +- src/ui/character/CharacterSheet.ts | 2 +- src/ui/common/Animations.ts | 4 ++-- src/ui/common/Tools.ts | 2 +- src/ui/map/StarSystemDisplay.ts | 2 +- tsconfig.json | 5 +---- 13 files changed, 20 insertions(+), 23 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 61ae0f7..c7c1623 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,3 @@ { - "typescript.check.workspaceVersion": false, "typescript.tsdk": "./node_modules/typescript/lib" } \ No newline at end of file diff --git a/package.json b/package.json index 4d8e90b..6474803 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "license": "MIT", "devDependencies": { "bower": "~1.8", - "codecov": "~1.0", + "codecov": "~2.1", "jasmine": "~2.5", "karma": "~1.5", "karma-coverage": "~1.1", @@ -28,7 +28,7 @@ "karma-phantomjs-launcher": "~1.0", "remap-istanbul": "~0.9", "live-server": "~1.2", - "typescript": "~2.2", + "typescript": "~2.3", "typings": "~2.1" } } \ No newline at end of file diff --git a/src/MainUI.spec.ts b/src/MainUI.spec.ts index 20672bb..8efe989 100644 --- a/src/MainUI.spec.ts +++ b/src/MainUI.spec.ts @@ -4,7 +4,7 @@ if (typeof window != "undefined") { module TS.SpaceTac.Specs { class FakeStorage { - data = {} + data: any = {} getItem(name: string) { return this.data[name]; } diff --git a/src/common b/src/common index 78179da..28bf87b 160000 --- a/src/common +++ b/src/common @@ -1 +1 @@ -Subproject commit 78179da26a37232fcc25a2df9109dc9c2124ec76 +Subproject commit 28bf87b126d13f3144955cba4c07bbe03c65e224 diff --git a/src/core/Equipment.ts b/src/core/Equipment.ts index c3a76cc..a011da2 100644 --- a/src/core/Equipment.ts +++ b/src/core/Equipment.ts @@ -75,7 +75,7 @@ module TS.SpaceTac { */ getFullDescription(): string { let requirements: string[] = []; - iteritems(this.requirements, (skill, value) => { + iteritems(this.requirements, (skill: keyof ShipAttributes, value) => { if (value > 0) { requirements.push(`- ${SHIP_ATTRIBUTES[skill].name} ${value}`); } @@ -114,7 +114,7 @@ module TS.SpaceTac { /** * Returns true if the equipment can be equipped on a ship with given skills. * - * This checks *requirements* against the skills. + * This checks *requirements* against the effective (modified) skills. * * This does not check where the equipment currently is (except if is it already attached and should be detached first). */ @@ -123,7 +123,7 @@ module TS.SpaceTac { return false; } else { var able = true; - iteritems(this.requirements, (attr, minvalue) => { + iteritems(this.requirements, (attr: keyof ShipAttributes, minvalue) => { if (skills[attr].get() < minvalue) { able = false; } diff --git a/src/core/LootGenerator.ts b/src/core/LootGenerator.ts index 960ca93..ac480d9 100644 --- a/src/core/LootGenerator.ts +++ b/src/core/LootGenerator.ts @@ -20,11 +20,12 @@ module TS.SpaceTac { // Fill the list of templates populate(): void { - var templates: LootTemplate[] = []; - for (var template_name in TS.SpaceTac.Equipments) { + let templates: LootTemplate[] = []; + let namespace: any = TS.SpaceTac.Equipments; + for (var template_name in namespace) { if (template_name && template_name.indexOf("Abstract") != 0) { - var template_class = TS.SpaceTac.Equipments[template_name]; - var template: LootTemplate = new template_class(); + let template_class = namespace[template_name]; + let template: LootTemplate = new template_class(); templates.push(template); } } diff --git a/src/core/Ship.ts b/src/core/Ship.ts index 59ead07..66c26b4 100644 --- a/src/core/Ship.ts +++ b/src/core/Ship.ts @@ -628,7 +628,7 @@ module TS.SpaceTac { // TODO better typing for iteritems // Apply base skills - iteritems(this.skills, (key, skill: ShipAttribute) => { + iteritems(this.skills, (key: keyof ShipAttributes, skill: ShipAttribute) => { new_attrs[key].add(skill.get()); }); diff --git a/src/core/ai/TacticalAI.ts b/src/core/ai/TacticalAI.ts index 3531ac3..aa1b4a8 100644 --- a/src/core/ai/TacticalAI.ts +++ b/src/core/ai/TacticalAI.ts @@ -99,7 +99,7 @@ module TS.SpaceTac { * Setup the default set of maneuver evaluators */ private setupDefaultEvaluators() { - let scaled = (evaluator: (...args) => number, factor: number) => (...args) => factor * evaluator(...args); + let scaled = (evaluator: (...args: any[]) => number, factor: number) => (...args: any[]) => factor * evaluator(...args); let evaluators = [ scaled(TacticalAIHelpers.evaluateTurnCost, 1), scaled(TacticalAIHelpers.evaluateDamageToEnemy, 30), diff --git a/src/ui/character/CharacterSheet.ts b/src/ui/character/CharacterSheet.ts index 48c3b11..c962698 100644 --- a/src/ui/character/CharacterSheet.ts +++ b/src/ui/character/CharacterSheet.ts @@ -156,7 +156,7 @@ module TS.SpaceTac.UI { this.attributes[SHIP_ATTRIBUTES[attribute].name] = text; - if (SHIP_SKILLS[attribute]) { + if (SHIP_SKILLS.hasOwnProperty(attribute)) { let button = new Phaser.Button(this.game, x + 54, y - 4, "character-skill-upgrade", () => { this.ship.upgradeSkill(attribute); this.refresh(); diff --git a/src/ui/common/Animations.ts b/src/ui/common/Animations.ts index 4a7a100..d2ae8a3 100644 --- a/src/ui/common/Animations.ts +++ b/src/ui/common/Animations.ts @@ -125,7 +125,7 @@ module TS.SpaceTac.UI { let duration = distance * 1000 / speed; // Update the tween - let changes = {}; + let changes: any = {}; changes[property] = dest; tween.to(changes, duration, easing); @@ -152,7 +152,7 @@ module TS.SpaceTac.UI { x: [obj.x + Math.cos(rotated_obj.rotation) * curve_force, x - Math.cos(angle) * curve_force, x], y: [obj.y + Math.sin(rotated_obj.rotation) * curve_force, y - Math.sin(angle) * curve_force, y] }, duration, Phaser.Easing.Sinusoidal.InOut); - tween.interpolation((v, k) => Phaser.Math.bezierInterpolation(v, k)); + tween.interpolation((v: any, k: any) => Phaser.Math.bezierInterpolation(v, k)); let prevx = obj.x; let prevy = obj.y; tween.onUpdateCallback(() => { diff --git a/src/ui/common/Tools.ts b/src/ui/common/Tools.ts index b9d6ab6..a87f4b1 100644 --- a/src/ui/common/Tools.ts +++ b/src/ui/common/Tools.ts @@ -50,7 +50,7 @@ module TS.SpaceTac.UI { */ static setHoverClick(obj: Phaser.Button, enter: Function, leave: Function, click: Function, hovertime = 300, holdtime = 600) { let holdstart = new Date(); - let enternext = null; + let enternext: Function | null = null; let entercalled = false; let cursorinside = false; diff --git a/src/ui/map/StarSystemDisplay.ts b/src/ui/map/StarSystemDisplay.ts index 9ed6244..68ee129 100644 --- a/src/ui/map/StarSystemDisplay.ts +++ b/src/ui/map/StarSystemDisplay.ts @@ -81,7 +81,7 @@ module TS.SpaceTac.UI { return image; } - addCircle(radius, width = 3, color = 0x424242): Phaser.Graphics { + addCircle(radius: number, width = 3, color = 0x424242): Phaser.Graphics { let circle = this.game.add.graphics(0, 0); circle.lineStyle(width, color); circle.drawCircle(0, 0, radius * 2 / this.scale.x); diff --git a/tsconfig.json b/tsconfig.json index 56d14a4..bac090e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,13 @@ { "compilerOptions": { - "alwaysStrict": true, "module": "system", "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, - "noImplicitAny": false, - "noImplicitThis": true, "noImplicitReturns": true, "removeComments": true, "preserveConstEnums": true, "out": "out/build.js", - "strictNullChecks": true, + "strict": true, "sourceMap": true, "target": "es5" },