Skip to content

Commit eb4f540

Browse files
committed
Remove strict deprecations about "any" types
1 parent 6ed9158 commit eb4f540

File tree

6 files changed

+34
-29
lines changed

6 files changed

+34
-29
lines changed

build/index.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ var App = /** @class */ (function () {
3030
this.refreshRandomPattern();
3131
};
3232
App.prototype.refreshRandomPattern = function () {
33-
// const handpan_notes = handpan_notes_input.value;
3433
var number_of_bars = Number(this.number_of_bars_input.value);
35-
var rhythm = App.getRadioButtonValue(this.rhythm_inputs);
36-
// handpan_notes_result_element.innerText = handpan_notes;
34+
var rhythm = parseInt(App.getRadioButtonValue(this.rhythm_inputs), 10);
3735
this.number_of_bars_result_element.innerText = String(number_of_bars);
38-
this.patterns_container.setAttribute('data-rhythm', rhythm);
36+
this.patterns_container.setAttribute('data-rhythm', rhythm.toString());
3937
this.patterns_container.innerHTML = '';
4038
var number_of_notes = number_of_bars * rhythm;
4139
this._currentPattern = new Pattern(rhythm, this.handpan_tune);
@@ -48,13 +46,16 @@ var App = /** @class */ (function () {
4846
console.info('Pattern:', this._currentPattern);
4947
};
5048
App.getRadioButtonValue = function (radios_list) {
51-
for (var _i = 0, radios_list_1 = radios_list; _i < radios_list_1.length; _i++) {
52-
var item = radios_list_1[_i];
49+
var value = '';
50+
radios_list.forEach(function (item) {
51+
if (!(item instanceof HTMLInputElement)) {
52+
return;
53+
}
5354
if (item.checked) {
54-
return item.value;
55+
value = item.value;
5556
}
56-
}
57-
return null;
57+
});
58+
return value;
5859
};
5960
return App;
6061
}());
@@ -64,7 +65,7 @@ var Hand;
6465
Hand[Hand["right"] = 1] = "right";
6566
})(Hand || (Hand = {}));
6667
var HandpanHit = /** @class */ (function () {
67-
function HandpanHit(hit_type, hand, notes) {
68+
function HandpanHit(hit_type, hand) {
6869
this.hit_type = hit_type;
6970
this.hand = hand;
7071
}
@@ -75,7 +76,7 @@ var HandpanHit = /** @class */ (function () {
7576
var random_boolean = Math.floor(Math.random() * 2);
7677
var hand = random_boolean ? Hand.left : Hand.right;
7778
var hit_type = HitType.getRandomHitType();
78-
return new HandpanHit(hit_type, hand, []);
79+
return new HandpanHit(hit_type, hand);
7980
};
8081
return HandpanHit;
8182
}());

src/App.ts

+15-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class App {
1515

1616
private _running: boolean = false;
1717

18-
private _currentPattern: Pattern<HandpanHit>;
18+
private _currentPattern: Pattern;
1919
private _patternRenderer: PatternRenderer;
2020

2121
constructor(
@@ -65,19 +65,17 @@ class App {
6565
}
6666

6767
refreshRandomPattern(): void {
68-
// const handpan_notes = handpan_notes_input.value;
6968
const number_of_bars = Number(this.number_of_bars_input.value);
70-
const rhythm = App.getRadioButtonValue(this.rhythm_inputs);
69+
const rhythm = parseInt(App.getRadioButtonValue(this.rhythm_inputs), 10);
7170

72-
// handpan_notes_result_element.innerText = handpan_notes;
7371
this.number_of_bars_result_element.innerText = String(number_of_bars);
7472

75-
this.patterns_container.setAttribute('data-rhythm', rhythm);
73+
this.patterns_container.setAttribute('data-rhythm', rhythm.toString());
7674
this.patterns_container.innerHTML = '';
7775

7876
let number_of_notes = number_of_bars * rhythm;
7977

80-
this._currentPattern = new Pattern<HandpanHit>(rhythm, this.handpan_tune);
78+
this._currentPattern = new Pattern(rhythm, this.handpan_tune);
8179

8280
for (let i = 0; i < number_of_notes; i++) {
8381
// Choose a "hit" type randomly in the list
@@ -91,13 +89,19 @@ class App {
9189
console.info('Pattern:', this._currentPattern);
9290
}
9391

94-
private static getRadioButtonValue(radios_list) {
95-
for (let item of radios_list) {
92+
private static getRadioButtonValue(radios_list: NodeList): string {
93+
let value = '';
94+
95+
radios_list.forEach(function (item: Node) {
96+
if (!(item instanceof HTMLInputElement)) {
97+
return;
98+
}
99+
96100
if (item.checked) {
97-
return item.value;
101+
value = item.value;
98102
}
99-
}
103+
});
100104

101-
return null;
105+
return value;
102106
}
103107
}

src/HandpanHit.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ class HandpanHit {
33
public readonly hit_type: HitType;
44
public readonly hand: Hand;
55

6-
private constructor(hit_type: HitType, hand: Hand, notes) {
6+
private constructor(hit_type: HitType, hand: Hand) {
77
this.hit_type = hit_type;
88
this.hand = hand;
99
}
1010

1111
/**
1212
* @param pattern to add logic instead of randomness when generating a pattern
1313
*/
14-
public static createRandomHit(pattern: Pattern<HandpanHit>): HandpanHit {
14+
public static createRandomHit(pattern: Pattern): HandpanHit {
1515
let random_boolean = Math.floor(Math.random() * 2);
1616
let hand = random_boolean ? Hand.left : Hand.right;
1717
let hit_type = HitType.getRandomHitType();
1818

19-
return new HandpanHit(hit_type, hand, []);
19+
return new HandpanHit(hit_type, hand);
2020
}
2121
}

src/Pattern.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Pattern<HandpanHit> {
1+
class Pattern {
22
private readonly _hits: Array<HandpanHit> = [];
33
private readonly _handpan_tune: HandpanTune;
44

src/PatternRenderer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class PatternRenderer {
77
this.container = container;
88
}
99

10-
public renderPattern(pattern: Pattern<HandpanHit>): void {
10+
public renderPattern(pattern: Pattern): void {
1111
let number_of_notes = pattern.count;
1212

1313
let i = 0;
@@ -34,7 +34,7 @@ class PatternRenderer {
3434
}
3535
}
3636

37-
private createPatternItem(pattern: Pattern<HandpanHit>, handpan_hit: HandpanHit): HTMLElement {
37+
private createPatternItem(pattern: Pattern, handpan_hit: HandpanHit): HTMLElement {
3838
const pattern_item = document.createElement('div');
3939
pattern_item.className = 'pattern_item';
4040

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"incremental": true,
44
"target": "es5",
55
"module": "none",
6-
"noImplicitAny": false,
6+
"noImplicitAny": true,
77
"outFile": "./build/index.js",
88
"strict": true
99
},

0 commit comments

Comments
 (0)