Make more code conform to strict null checks (#10219

* Make more code conform to strict null checks

* Fix types

* Fix tests

* Fix remaining test assertions

* Iterate PR
This commit is contained in:
Michael Telatynski 2023-02-24 15:28:40 +00:00 committed by GitHub
parent 4c79ecf141
commit 76b82b4b2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
130 changed files with 603 additions and 603 deletions

View file

@ -15,10 +15,10 @@ limitations under the License.
*/
export const parseGeoUri = (uri: string): GeolocationCoordinates | undefined => {
function parse(s: string): number | undefined {
function parse(s: string): number | null {
const ret = parseFloat(s);
if (Number.isNaN(ret)) {
return undefined;
return null;
} else {
return ret;
}
@ -28,7 +28,7 @@ export const parseGeoUri = (uri: string): GeolocationCoordinates | undefined =>
if (!m) return;
const parts = m[1].split(";");
const coords = parts[0].split(",");
let uncertainty: number | undefined;
let uncertainty: number | null;
for (const param of parts.slice(1)) {
const m = param.match(/u=(.*)/);
if (m) uncertainty = parse(m[1]);
@ -38,8 +38,8 @@ export const parseGeoUri = (uri: string): GeolocationCoordinates | undefined =>
longitude: parse(coords[1]),
altitude: parse(coords[2]),
accuracy: uncertainty,
altitudeAccuracy: undefined,
heading: undefined,
speed: undefined,
altitudeAccuracy: null,
heading: null,
speed: null,
};
};