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

Types for Astal services not entirely accurate. #651

Open
Jas-SinghFSU opened this issue Dec 17, 2024 · 1 comment
Open

Types for Astal services not entirely accurate. #651

Jas-SinghFSU opened this issue Dec 17, 2024 · 1 comment

Comments

@Jas-SinghFSU
Copy link

I see that ts-for-gir is being used to generate types for Typescript but I have noticed some discrepancies in types for various different Astal services. Some notable culprits are:

  1. AstalNetwork.Wifi - can be null but isn't typed accordingly. Which leads to startup errors if bindings are relying on a null value or if a property of a null Wifi (imagine no wifi adapter exists) is getting accessed.
  2. AstalBluetooth.Adapter - same as above
  3. AstalNetwork.Wired - same as above

Culprit example:

bind(networkService.wifi, 'iconName')

This will fail and prevent the component from rendering if networkService.wifi is null. However, the type definition doesn't indicate that this can be null in the absence of a wifi adapter.

@kotontrion
Copy link
Contributor

yeah. They are marked as nullable in vala, and the generated vapi files are correct. They are not marked as nullable in the gir file, I had a quick look and couldn't find any evidence that properties can even be marked as nullable in gir files at all. The return type of getter functions is correct though.So eg networkService.get_wifi() has return type Wifi | null

Object type properties might be inherently nullable (not sure though, would need to read through all the gobject introspection stuff to find out), then the this has to be fixed in ts-for-gir.

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

No branches or pull requests

2 participants