aurelia / dialog

A dialog plugin for Aurelia.
MIT License
106 stars 115 forks source link

Support typing the model with a generic type argument on the open method #392

Open davidlav opened 4 years ago

davidlav commented 4 years ago

I'm submitting a feature request

Current behavior: There is not an easy way to enforce type consistency in the data model passed through the open function and where it is consumed in the dialog view model's activate and canActivate functions.

StrahilKazlachev commented 4 years ago

Any suggestions/PRs how those can be coupled are welcomed.

In the case where viewModel is passed as string(moduleId) I doubt, something could be done. On another note, there are 4 interfaces currently, DialogComponentActivate, ... that can be used on the VM.

There is a similar problem how to propagate the dialog "output" type from the VM through the service.

m-gallesio commented 3 years ago

Typescript now provides ways to get the types of function parameters: https://www.typescriptlang.org/docs/handbook/utility-types.html#parameterstype Given this functionality I assume this request would be possible.