Skip to content

Commit

Permalink
♻️ (TypeScript) fix strictFunctionTypes violations (pt 2) (#2066)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis authored Dec 19, 2023
1 parent b385c71 commit c727e3e
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 15 deletions.
4 changes: 3 additions & 1 deletion packages/desktop-client/src/components/sidebar/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import ItemContent from './ItemContent';

type ItemProps = {
title: string;
Icon: ComponentType<SVGProps<SVGElement>>;
Icon:
| ComponentType<SVGProps<SVGElement>>
| ComponentType<SVGProps<SVGSVGElement>>;
to?: string;
children?: ReactNode;
style?: CSSProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const fontWeight = 600;
type SecondaryItemProps = {
title: string;
to?: string;
Icon?: ComponentType<SVGProps<SVGElement>>;
Icon?:
| ComponentType<SVGProps<SVGElement>>
| ComponentType<SVGProps<SVGSVGElement>>;
style?: CSSProperties;
onClick?: MouseEventHandler<HTMLDivElement>;
bold?: boolean;
Expand Down
10 changes: 7 additions & 3 deletions packages/desktop-client/src/components/sort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function useDraggable<T>({
}

export type OnDropCallback = (
id: unknown,
id: string,
dropPos: DropPosition,
targetId: unknown,
) => Promise<void> | void;
Expand All @@ -86,7 +86,7 @@ type UseDroppableArgs = {
onLongHover?: OnLongHoverCallback;
};

export function useDroppable({
export function useDroppable<T extends { id: string }>({
types,
id,
onDrop,
Expand All @@ -95,7 +95,11 @@ export function useDroppable({
const ref = useRef(null);
const [dropPos, setDropPos] = useState<DropPosition>(null);

const [{ isOver }, dropRef] = useDrop({
const [{ isOver }, dropRef] = useDrop<
{ item: T },
unknown,
{ isOver: boolean }
>({
accept: types,
drop({ item }) {
onDrop(item.id, dropPos, id);
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ export function SelectCell({
type SheetCellValueProps = {
binding: Binding;
type: string;
getValueStyle?: (value: unknown) => CSSProperties;
getValueStyle?: (value: string | number) => CSSProperties;
formatExpr?: (value) => string;
unformatExpr?: (value: string) => unknown;
privacyFilter?: ConditionalPrivacyFilterProps['privacyFilter'];
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@swc/core": "^1.3.82",
"@swc/helpers": "^0.5.1",
"@swc/jest": "^0.2.29",
"@types/better-sqlite3": "^7.6.7",
"@types/better-sqlite3": "^7.6.8",
"@types/jest": "^27.5.0",
"@types/jlongster__sql.js": "npm:@types/sql.js@latest",
"@types/pegjs": "^0.10.3",
Expand Down
6 changes: 3 additions & 3 deletions packages/loot-core/src/server/sync/sync.property.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const baseTime = 1565374471903;
const clientId1 = '80dd7da215247293';
const clientId2 = '90xU1sd5124329ac';

function makeGen({
function makeGen<T extends Arbitrary<unknown>>({
table,
row,
field,
Expand All @@ -102,7 +102,7 @@ function makeGen({
table: string;
row?: Arbitrary<string>;
field: string;
value: Arbitrary<unknown>;
value: T;
}) {
return jsc.record({
dataset: jsc.constant(table),
Expand All @@ -127,7 +127,7 @@ function makeGen({
});
}

const generators = [];
const generators: Array<ReturnType<typeof makeGen>> = [];
Object.keys(schema).forEach(table => {
Object.keys(schema[table]).reduce((obj, field) => {
if (table === 'spreadsheet_cells' && field === 'expr') {
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2066.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [MatissJanis]
---

Fixing TypeScript issues when enabling `strictFunctionTypes` (pt.2).
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4299,12 +4299,12 @@ __metadata:
languageName: node
linkType: hard

"@types/better-sqlite3@npm:^7.6.7":
version: 7.6.7
resolution: "@types/better-sqlite3@npm:7.6.7"
"@types/better-sqlite3@npm:^7.6.8":
version: 7.6.8
resolution: "@types/better-sqlite3@npm:7.6.8"
dependencies:
"@types/node": "npm:*"
checksum: 5021c1bae4a494408c1a77d84bc31dc15e373b8a1cf8880acba6517f63bc5c2dbf032c81938641346fb967600dbebc1475033c2458b5a5b93eb8f2c53bdbcbf8
checksum: 404e9b7210564866b0f8878353cc6a16c6ffb313077cbb5aec6176ad2b0a30f64236f03f0a40d36d86bf4eab7658bdcd6d6a8a65dc377de7910fc9e9932885a4
languageName: node
linkType: hard

Expand Down Expand Up @@ -13356,7 +13356,7 @@ __metadata:
"@swc/helpers": "npm:^0.5.1"
"@swc/jest": "npm:^0.2.29"
"@types/adm-zip": "npm:^0.5.0"
"@types/better-sqlite3": "npm:^7.6.7"
"@types/better-sqlite3": "npm:^7.6.8"
"@types/jest": "npm:^27.5.0"
"@types/jlongster__sql.js": "npm:@types/sql.js@latest"
"@types/pegjs": "npm:^0.10.3"
Expand Down

0 comments on commit c727e3e

Please sign in to comment.