-
Notifications
You must be signed in to change notification settings - Fork 7
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
When constructing St.Widget
, specifying layout_manager
should be reflected in types
#18
Comments
The two suggestions above still have a flaw: It now requires TypeScript user to pass If you want to fix this flaw, then I suggest stop using the const Widget: unknown
& (new <Config extends Widget.ConstructorProperties> (config: Config) => Widget<Config>)
& (new (config?: null) => Widget<null>)
interface Widget<Config extends Widget.ConstructorProperties | null> extends Widget.Actor<Config> {} As for me personally, whether I have to pass |
Hey @KSXGitHub, this repository is dedicated to the gnome-shell types that are usually imported through a The types related to I personally tend to define custom generic types when required. In my experience they are usually only needed in very few places. |
@schnz I have created |
When one constructs a
St.Widget
like this:The type of
myWidget.layout_manager
is stillLayoutManager
, which would make TypeScript errors when one tries to use methods fromGridLayout
.Suggestion 1: Multiple type parameters
WARNING:
ConstructorProperties
now shouldn't be a single interface, but a union of snake_case properties and camelCase properties. Keeping it as a single interface would have required user to specify bothlayout_manager
andlayoutManager
, which would be absurd.Suggestion 2: Type dictionary as a single type parameter
NOTE: I strongly recommend this solution.
ConstructorProperties
does not need to change at all.The text was updated successfully, but these errors were encountered: