Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: TypeScript errors #332

Merged
merged 3 commits into from
Mar 7, 2024
Merged

fix: TypeScript errors #332

merged 3 commits into from
Mar 7, 2024

Conversation

h-banii
Copy link
Contributor

@h-banii h-banii commented Mar 3, 2024

Fixes #312 (typescript errors)

Not sure why only in Fedora (typescript version is 5.1.3), but I managed to fix these errors.
I know why this happens, it's because of the typescript version, alternative solution in this other PR #333

Apparently, all tuple members must have names (or no names)

../src/utils/binding.ts(35,62): error TS5084: Tuple members must all have names or all not have names.
../src/utils/binding.ts(40,46): error TS5084: Tuple members must all have names or all not have names.

- [Connectable, signal?: string]
+ [obj: Connectable, signal?: string]

It assumes that empty array [] to be of type never[], and for some reason it says "reduce" isn't callable? This can be fixed by using new Array instead of [] (but the linter complains about it) or just define the type to be any[].

../src/widgets/widget.ts(249,29): error TS2349: This expression is not callable.
  Each member of the union type '{ (callbackfn: (previousValue: "SHIFT" | "LOCK" | "CONTROL" | "MOD1" | "MOD2" | "MOD3" | "MOD4" | "MOD5" | "BUTTON1" | "BUTTON2" | "BUTTON3" | "BUTTON4" | "BUTTON5" | "MODIFIER_RESERVED_13" | "MODIFIER_RESERVED_14" | ... 16 more ... | "MODIFIER", currentValue: "SHIFT" | ... 30 more ... | "MODIFIER", currentIndex: nu...' has signatures, but none of those signatures are compatible with each other.
../src/widgets/widget.ts(249,37): error TS7006: Parameter 'ms' implicitly has an 'any' type.
../src/widgets/widget.ts(249,41): error TS7006: Parameter 'm' implicitly has an 'any' type.

- const mods = callback ? modsOrKey as Mod : [];
+ const mods = callback ? modsOrKey as Mod : [] as any[];

This one complains that the index `${m}_MASK` isn't a number...

../src/widgets/widget.ts(249,69): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'.

- const ms = mods.reduce((ms, m) => ms | Gdk.ModifierType[`${m}_MASK`], 0);
+ const ms = mods.reduce(
+     (ms, m) => ms | Gdk.ModifierType[`${m}_MASK` as keyof typeof Gdk.ModifierType],
+     0,
+ );

@h-banii
Copy link
Contributor Author

h-banii commented Mar 3, 2024

before

image

after

image

@Aylur Aylur merged commit 6ac6c92 into Aylur:main Mar 7, 2024
2 checks passed
@h-banii h-banii deleted the fix/typescript-errors branch March 8, 2024 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build on Fedora is not working
2 participants