"fix" ts failing in CI due to improved upstream type signatures

...by throwing non-null assertions everywhere.
This commit is contained in:
Damien Elmes 2020-09-29 22:13:25 +10:00
parent 955c1bafb9
commit 70a73b7c60
9 changed files with 54 additions and 54 deletions

View File

@ -9,7 +9,7 @@
"@pyoner/svelte-types": "^3.4.4-2",
"@types/d3-array": "^2.0.0",
"@types/d3-axis": "^1.0.12",
"@types/d3-scale": "^2.2.0",
"@types/d3-scale": "^2.2.1",
"@types/d3-scale-chromatic": "^1.5.0",
"@types/d3-selection": "^1.4.1",
"@types/d3-shape": "^1.3.2",
@ -27,19 +27,19 @@
"eslint": "^6.7.2",
"eslint-loader": "^4.0.2",
"eslint-plugin-svelte3": "^2.7.3",
"html-webpack-plugin": "^4.3.0",
"prettier": "^2.1.1",
"prettier-plugin-svelte": "^1.1.1",
"sass": "^1.26.9",
"html-webpack-plugin": "^4.5.0",
"prettier": "^2.1.2",
"prettier-plugin-svelte": "^1.4.0",
"sass": "^1.26.11",
"sass-loader": "^8.0.2",
"style-loader": "^1.2.1",
"svelte": "^3.23.2",
"svelte": "^3.28.0",
"svelte-check": "^0.1.59",
"svelte-loader": "^2.13.6",
"svelte-preprocess": "^3.9.9",
"ts-loader": "^7.0.5",
"typescript": "^3.9.7",
"webpack": "^4.44.0",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.11.0"
},
@ -51,10 +51,10 @@
},
"dependencies": {
"@fluent/bundle": "^0.15.1",
"d3-array": "^2.6.0",
"d3-array": "^2.8.0",
"d3-axis": "^1.0.12",
"d3-interpolate": "^1.4.0",
"d3-scale": "^3.2.2",
"d3-scale": "^3.2.3",
"d3-scale-chromatic": "^1.5.0",
"d3-selection": "^1.4.2",
"d3-shape": "^1.3.7",

View File

@ -70,7 +70,7 @@ export function buildHistogram(
const adjustedRange = scaleLinear().range([0.7, 0.3]);
const colourScale = scaleSequential((n) =>
interpolateBlues(adjustedRange(n))
interpolateBlues(adjustedRange(n)!)
).domain([xMax!, xMin!]);
const totalInPeriod = sum(bins, (bin) => bin.length);

View File

@ -204,7 +204,7 @@ export function renderButtons(
(d: Datum) => xGroup(d.group)! + xButton(d.buttonNum.toString())!
)
.attr("y", (d: Datum) => y(d.count)!)
.attr("height", (d: Datum) => y(0) - y(d.count))
.attr("height", (d: Datum) => y(0)! - y(d.count)!)
.attr("fill", (d: Datum) => colour(d.buttonNum));
};
@ -221,13 +221,13 @@ export function renderButtons(
(d: Datum) =>
xGroup(d.group)! + xButton(d.buttonNum.toString())!
)
.attr("y", y(0))
.attr("y", y(0)!)
.attr("height", 0)
.call(updateBar),
(update) => update.call(updateBar),
(remove) =>
remove.call((remove) =>
remove.transition(trans).attr("height", 0).attr("y", y(0))
remove.transition(trans).attr("height", 0).attr("y", y(0)!)
)
);
@ -248,9 +248,9 @@ export function renderButtons(
.data(data)
.join("rect")
.attr("x", (d: Datum) => xGroup(d.group)! + xButton(d.buttonNum.toString())!)
.attr("y", () => y(yMax!))
.attr("y", () => y(yMax!)!)
.attr("width", xButton.bandwidth())
.attr("height", () => y(0) - y(yMax!))
.attr("height", () => y(0)! - y(yMax!)!)
.on("mousemove", function (this: any, d: Datum) {
const [x, y] = mouse(document.body);
showTooltip(tooltipText(d), x, y);

View File

@ -118,7 +118,7 @@ export function renderCalendar(
}
const data = Array.from(dayMap.values());
const cappedRange = scaleLinear().range([0.2, nightMode ? 0.8 : 1]);
const blues = scaleSequential((n) => interpolateBlues(cappedRange(n))).domain([
const blues = scaleSequential((n) => interpolateBlues(cappedRange(n)!)).domain([
0,
maxCount,
]);
@ -145,10 +145,10 @@ export function renderCalendar(
.join("rect")
.attr("fill", emptyColour)
.attr("width", (d) => {
return x(d.weekNumber + 1) - x(d.weekNumber) - 2;
return x(d.weekNumber + 1)! - x(d.weekNumber)! - 2;
})
.attr("height", height - 2)
.attr("x", (d) => x(d.weekNumber))
.attr("x", (d) => x(d.weekNumber)!)
.attr("y", (d) => bounds.marginTop + d.weekDay * height)
.on("mousemove", function (this: any, d: any) {
const [x, y] = mouse(document.body);
@ -161,7 +161,7 @@ export function renderCalendar(
if (d.count === 0) {
return emptyColour;
} else {
return blues(d.count);
return blues(d.count)!;
}
});
}

View File

@ -118,7 +118,7 @@ export function buildHistogram(
const adjustedRange = scaleLinear().range([0.7, 0.3]);
const colourScale = scaleSequential((n) =>
interpolateGreens(adjustedRange(n))
interpolateGreens(adjustedRange(n)!)
).domain([xMin!, xMax!]);
const total = sum(bins as any, binValue);

View File

@ -76,7 +76,7 @@ export function histogramGraph(
// x bars
function barWidth(d: any): number {
const width = Math.max(0, x(d.x1) - x(d.x0) - 1);
const width = Math.max(0, x(d.x1)! - x(d.x0)! - 1);
return width ? width : 0;
}
@ -86,7 +86,7 @@ export function histogramGraph(
.transition(trans)
.attr("x", (d: any) => x(d.x0))
.attr("y", (d: any) => y(binValue(d))!)
.attr("height", (d: any) => y(0) - y(binValue(d)))
.attr("height", (d: any) => y(0)! - y(binValue(d))!)
.attr("fill", (d) => data.colourScale(d.x1));
};
@ -98,14 +98,14 @@ export function histogramGraph(
enter
.append("rect")
.attr("rx", 1)
.attr("x", (d: any) => x(d.x0))
.attr("y", y(0))
.attr("x", (d: any) => x(d.x0)!)
.attr("y", y(0)!)
.attr("height", 0)
.call(updateBar),
(update) => update.call(updateBar),
(remove) =>
remove.call((remove) =>
remove.transition(trans).attr("height", 0).attr("y", y(0))
remove.transition(trans).attr("height", 0).attr("y", y(0)!)
)
);
@ -133,13 +133,13 @@ export function histogramGraph(
.curve(curveBasis)
.x((d, idx) => {
if (idx === 0) {
return x(data.bins[0].x0!);
return x(data.bins[0].x0!)!;
} else {
return x(data.bins[idx - 1].x1!);
return x(data.bins[idx - 1].x1!)!;
}
})
.y0(bounds.height - bounds.marginBottom)
.y1((d: any) => yAreaScale(d)) as any
.y1((d: any) => yAreaScale(d)!) as any
);
}
@ -148,10 +148,10 @@ export function histogramGraph(
.selectAll("rect")
.data(data.bins)
.join("rect")
.attr("x", (d: any) => x(d.x0))
.attr("y", () => y(yMax!))
.attr("x", (d: any) => x(d.x0)!)
.attr("y", () => y(yMax!)!)
.attr("width", barWidth)
.attr("height", () => y(0) - y(yMax!))
.attr("height", () => y(0)! - y(yMax!)!)
.on("mousemove", function (this: any, d: any, idx) {
const [x, y] = mouse(document.body);
const pct = data.showArea ? (areaData[idx + 1] / data.total) * 100 : 0;

View File

@ -96,7 +96,7 @@ export function renderHours(
});
const cappedRange = scaleLinear().range([0.1, 0.8]);
const colour = scaleSequential((n) => interpolateBlues(cappedRange(n))).domain([
const colour = scaleSequential((n) => interpolateBlues(cappedRange(n)!)).domain([
0,
yMax,
]);
@ -125,7 +125,7 @@ export function renderHours(
.transition(trans)
.attr("x", (d: Hour) => x(d.hour.toString())!)
.attr("y", (d: Hour) => y(d.totalCount)!)
.attr("height", (d: Hour) => y(0) - y(d.totalCount))
.attr("height", (d: Hour) => y(0)! - y(d.totalCount)!)
.attr("fill", (d: Hour) => colour(d.totalCount!));
};
@ -138,14 +138,14 @@ export function renderHours(
.append("rect")
.attr("rx", 1)
.attr("x", (d: Hour) => x(d.hour.toString())!)
.attr("y", y(0))
.attr("y", y(0)!)
.attr("height", 0)
// .attr("opacity", 0.7)
.call(updateBar),
(update) => update.call(updateBar),
(remove) =>
remove.call((remove) =>
remove.transition(trans).attr("height", 0).attr("y", y(0))
remove.transition(trans).attr("height", 0).attr("y", y(0)!)
)
);
@ -171,7 +171,7 @@ export function renderHours(
.y0(bounds.height - bounds.marginBottom)
.y1((d: Hour) => {
const correctRatio = d.correctCount! / d.totalCount!;
return yArea(isNaN(correctRatio) ? 0 : correctRatio);
return yArea(isNaN(correctRatio) ? 0 : correctRatio)!;
})
);
@ -196,7 +196,7 @@ export function renderHours(
.attr("x", (d: Hour) => x(d.hour.toString())!)
.attr("y", () => y(yMax)!)
.attr("width", x.bandwidth())
.attr("height", () => y(0) - y(yMax!))
.attr("height", () => y(0)! - y(yMax!)!)
.on("mousemove", function (this: any, d: Hour) {
const [x, y] = mouse(document.body);
showTooltip(tooltipText(d), x, y);

View File

@ -103,7 +103,7 @@ export function prepareIntervalData(
const adjustedRange = scaleLinear().range([0.7, 0.3]);
const colourScale = scaleSequential((n) =>
interpolateBlues(adjustedRange(n))
interpolateBlues(adjustedRange(n)!)
).domain([xMax!, xMin!]);
function hoverText(

View File

@ -191,25 +191,25 @@ export function renderReviews(
// x bars
function barWidth(d: any): number {
const width = Math.max(0, x(d.x1) - x(d.x0) - 1);
const width = Math.max(0, x(d.x1)! - x(d.x0)! - 1);
return width ? width : 0;
}
const cappedRange = scaleLinear().range([0.3, 0.5]);
const shiftedRange = scaleLinear().range([0.4, 0.7]);
const darkerGreens = scaleSequential((n) =>
interpolateGreens(shiftedRange(n))
interpolateGreens(shiftedRange(n)!)
).domain(x.domain() as any);
const lighterGreens = scaleSequential((n) =>
interpolateGreens(cappedRange(n))
interpolateGreens(cappedRange(n)!)
).domain(x.domain() as any);
const blues = scaleSequential((n) => interpolateBlues(cappedRange(n))).domain(
const blues = scaleSequential((n) => interpolateBlues(cappedRange(n)!)).domain(
x.domain() as any
);
const reds = scaleSequential((n) => interpolateReds(cappedRange(n))).domain(
const reds = scaleSequential((n) => interpolateReds(cappedRange(n)!)).domain(
x.domain() as any
);
const oranges = scaleSequential((n) => interpolateOranges(cappedRange(n))).domain(
const oranges = scaleSequential((n) => interpolateOranges(cappedRange(n)!)).domain(
x.domain() as any
);
@ -269,7 +269,7 @@ export function renderReviews(
.transition(trans)
.attr("x", (d: any) => x(d.x0))
.attr("y", (d: any) => y(cumulativeBinValue(d, idx))!)
.attr("height", (d: any) => y(0) - y(cumulativeBinValue(d, idx)))
.attr("height", (d: any) => y(0)! - y(cumulativeBinValue(d, idx))!)
.attr("fill", (d: any) => {
switch (idx) {
case 0:
@ -295,14 +295,14 @@ export function renderReviews(
enter
.append("rect")
.attr("rx", 1)
.attr("x", (d: any) => x(d.x0))
.attr("y", y(0))
.attr("x", (d: any) => x(d.x0)!)
.attr("y", y(0)!)
.attr("height", 0)
.call((d) => updateBar(d, barNum)),
(update) => update.call((d) => updateBar(d, barNum)),
(remove) =>
remove.call((remove) =>
remove.transition(trans).attr("height", 0).attr("y", y(0))
remove.transition(trans).attr("height", 0).attr("y", y(0)!)
)
);
}
@ -333,13 +333,13 @@ export function renderReviews(
.curve(curveBasis)
.x((d, idx) => {
if (idx === 0) {
return x(bins[0].x0!);
return x(bins[0].x0!)!;
} else {
return x(bins[idx - 1].x1!);
return x(bins[idx - 1].x1!)!;
}
})
.y0(bounds.height - bounds.marginBottom)
.y1((d: any) => yAreaScale(d)) as any
.y1((d: any) => yAreaScale(d)!) as any
);
}
@ -348,10 +348,10 @@ export function renderReviews(
.selectAll("rect")
.data(bins)
.join("rect")
.attr("x", (d: any) => x(d.x0))
.attr("y", () => y(yMax!))
.attr("x", (d: any) => x(d.x0)!)
.attr("y", () => y(yMax!)!)
.attr("width", barWidth)
.attr("height", () => y(0) - y(yMax!))
.attr("height", () => y(0)! - y(yMax!)!)
.on("mousemove", function (this: any, d: any, idx) {
const [x, y] = mouse(document.body);
showTooltip(tooltipText(d, areaData[idx + 1]), x, y);