From c727e3e980f9563e834c8b0e7b74ab6b090b5b20 Mon Sep 17 00:00:00 2001 From: Matiss Janis Aboltins Date: Tue, 19 Dec 2023 18:01:06 +0000 Subject: [PATCH] :recycle: (TypeScript) fix strictFunctionTypes violations (pt 2) (#2066) --- .../desktop-client/src/components/sidebar/Item.tsx | 4 +++- .../src/components/sidebar/SecondaryItem.tsx | 4 +++- packages/desktop-client/src/components/sort.tsx | 10 +++++++--- packages/desktop-client/src/components/table.tsx | 2 +- packages/loot-core/package.json | 2 +- .../loot-core/src/server/sync/sync.property.test.ts | 6 +++--- upcoming-release-notes/2066.md | 6 ++++++ yarn.lock | 10 +++++----- 8 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 upcoming-release-notes/2066.md diff --git a/packages/desktop-client/src/components/sidebar/Item.tsx b/packages/desktop-client/src/components/sidebar/Item.tsx index 32ec1c87ef6..043e44d4123 100644 --- a/packages/desktop-client/src/components/sidebar/Item.tsx +++ b/packages/desktop-client/src/components/sidebar/Item.tsx @@ -13,7 +13,9 @@ import ItemContent from './ItemContent'; type ItemProps = { title: string; - Icon: ComponentType>; + Icon: + | ComponentType> + | ComponentType>; to?: string; children?: ReactNode; style?: CSSProperties; diff --git a/packages/desktop-client/src/components/sidebar/SecondaryItem.tsx b/packages/desktop-client/src/components/sidebar/SecondaryItem.tsx index dbe355c35e7..0780acbfb4e 100644 --- a/packages/desktop-client/src/components/sidebar/SecondaryItem.tsx +++ b/packages/desktop-client/src/components/sidebar/SecondaryItem.tsx @@ -16,7 +16,9 @@ const fontWeight = 600; type SecondaryItemProps = { title: string; to?: string; - Icon?: ComponentType>; + Icon?: + | ComponentType> + | ComponentType>; style?: CSSProperties; onClick?: MouseEventHandler; bold?: boolean; diff --git a/packages/desktop-client/src/components/sort.tsx b/packages/desktop-client/src/components/sort.tsx index 10e7d963d11..a3ce6cb883c 100644 --- a/packages/desktop-client/src/components/sort.tsx +++ b/packages/desktop-client/src/components/sort.tsx @@ -72,7 +72,7 @@ export function useDraggable({ } export type OnDropCallback = ( - id: unknown, + id: string, dropPos: DropPosition, targetId: unknown, ) => Promise | void; @@ -86,7 +86,7 @@ type UseDroppableArgs = { onLongHover?: OnLongHoverCallback; }; -export function useDroppable({ +export function useDroppable({ types, id, onDrop, @@ -95,7 +95,11 @@ export function useDroppable({ const ref = useRef(null); const [dropPos, setDropPos] = useState(null); - const [{ isOver }, dropRef] = useDrop({ + const [{ isOver }, dropRef] = useDrop< + { item: T }, + unknown, + { isOver: boolean } + >({ accept: types, drop({ item }) { onDrop(item.id, dropPos, id); diff --git a/packages/desktop-client/src/components/table.tsx b/packages/desktop-client/src/components/table.tsx index b85928335f1..92e2e833a47 100644 --- a/packages/desktop-client/src/components/table.tsx +++ b/packages/desktop-client/src/components/table.tsx @@ -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']; diff --git a/packages/loot-core/package.json b/packages/loot-core/package.json index 44c8460f753..d6c155b264f 100644 --- a/packages/loot-core/package.json +++ b/packages/loot-core/package.json @@ -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", diff --git a/packages/loot-core/src/server/sync/sync.property.test.ts b/packages/loot-core/src/server/sync/sync.property.test.ts index 9532405d486..346eb3f16ce 100644 --- a/packages/loot-core/src/server/sync/sync.property.test.ts +++ b/packages/loot-core/src/server/sync/sync.property.test.ts @@ -93,7 +93,7 @@ const baseTime = 1565374471903; const clientId1 = '80dd7da215247293'; const clientId2 = '90xU1sd5124329ac'; -function makeGen({ +function makeGen>({ table, row, field, @@ -102,7 +102,7 @@ function makeGen({ table: string; row?: Arbitrary; field: string; - value: Arbitrary; + value: T; }) { return jsc.record({ dataset: jsc.constant(table), @@ -127,7 +127,7 @@ function makeGen({ }); } -const generators = []; +const generators: Array> = []; Object.keys(schema).forEach(table => { Object.keys(schema[table]).reduce((obj, field) => { if (table === 'spreadsheet_cells' && field === 'expr') { diff --git a/upcoming-release-notes/2066.md b/upcoming-release-notes/2066.md new file mode 100644 index 00000000000..6ff11102d47 --- /dev/null +++ b/upcoming-release-notes/2066.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MatissJanis] +--- + +Fixing TypeScript issues when enabling `strictFunctionTypes` (pt.2). diff --git a/yarn.lock b/yarn.lock index 03925d9128b..03fe210bc28 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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 @@ -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"