Skip to content

Commit

Permalink
type fixes, js modernization
Browse files Browse the repository at this point in the history
  • Loading branch information
bdon committed Jan 23, 2024
1 parent 3082c04 commit e81165f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class TextAttr {
}
for (const property of label_props) {
if (
f.props.hasOwnProperty(property) &&
f.props.hasOwn(property) &&

Check failure on line 65 in src/attribute.ts

View workflow job for this annotation

GitHub Actions / test

Object is possibly 'null'.

Check failure on line 65 in src/attribute.ts

View workflow job for this annotation

GitHub Actions / test

Cannot invoke an object which is possibly 'null'.

Check failure on line 65 in src/attribute.ts

View workflow job for this annotation

GitHub Actions / test

This expression is not callable.
typeof f.props[property] === "string"
) {
retval = f.props[property] as string;
Expand Down
6 changes: 3 additions & 3 deletions src/compat/json_style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export function filterFn(arr: any[]): Filter {
return (z, f) => !arr.slice(2, arr.length).includes(f.props[arr[1]]);
}
if (arr[0] === "has") {
return (z, f) => f.props.hasOwnProperty(arr[1]);
return (z, f) => f.props.hasOwn(arr[1]);

Check failure on line 50 in src/compat/json_style.ts

View workflow job for this annotation

GitHub Actions / test

Cannot invoke an object which is possibly 'null'.

Check failure on line 50 in src/compat/json_style.ts

View workflow job for this annotation

GitHub Actions / test

This expression is not callable.
}
if (arr[0] === "!has") {
return (z, f) => !f.props.hasOwnProperty(arr[1]);
return (z, f) => !f.props.hasOwn(arr[1]);

Check failure on line 53 in src/compat/json_style.ts

View workflow job for this annotation

GitHub Actions / test

Cannot invoke an object which is possibly 'null'.

Check failure on line 53 in src/compat/json_style.ts

View workflow job for this annotation

GitHub Actions / test

This expression is not callable.
}
if (arr[0] === "all") {
const parts = arr.slice(1, arr.length).map((e) => filterFn(e));
Expand Down Expand Up @@ -141,7 +141,7 @@ interface FontSub {
export function getFont(obj: any, fontsubmap: any) {
const fontfaces: FontSub[] = [];
for (const wanted_face of obj["text-font"]) {
if (fontsubmap.hasOwnProperty(wanted_face)) {
if (fontsubmap.hasOwn(wanted_face)) {
fontfaces.push(fontsubmap[wanted_face]);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/default_style/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export const labelRules = (
}),
params.cityLabel,
),
sort: (a: any, b: any) => {
sort: (a: unknown, b: unknown) => {
return a["pmap:rank"] - b["pmap:rank"];

Check failure on line 406 in src/default_style/style.ts

View workflow job for this annotation

GitHub Actions / test

Object is of type 'unknown'.

Check failure on line 406 in src/default_style/style.ts

View workflow job for this annotation

GitHub Actions / test

Object is of type 'unknown'.
},
},
Expand Down Expand Up @@ -436,7 +436,7 @@ export const labelRules = (
params.cityLabel,
),
]),
sort: (a: any, b: any) => {
sort: (a: unknown, b: unknown) => {
return a["pmap:rank"] - b["pmap:rank"];

Check failure on line 440 in src/default_style/style.ts

View workflow job for this annotation

GitHub Actions / test

Object is of type 'unknown'.
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/labeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface LabelRule {
symbolizer: LabelSymbolizer;
filter?: Filter;
visible?: boolean;
sort?: (a: any, b: any) => number;
sort?: (a: unknown, b: unknown) => number;
}

export const covering = (
Expand Down
10 changes: 4 additions & 6 deletions src/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const linelabel = (
targetLen: number,
): LabelableSegment[] => {
const chunks = [];
let a;
let b;
let c;
let a: Point;
let b: Point;
let c: Point;
let i = 0;
let n = 0;
let d = 0;
Expand Down Expand Up @@ -91,13 +91,11 @@ export interface LabelCandidate {
}

export function simpleLabel(
mls: any,
mls: Point[][],
minimum: number,
repeatDistance: number,
cellSize: number,
): LabelCandidate[] {
let longestStart;
let longestEnd;
const longestLength = 0;

const candidates = [];
Expand Down

0 comments on commit e81165f

Please sign in to comment.