Skip to content

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

@davidlav

Description

@davidlav

I'm submitting a feature request

  • Language: TypeScript

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.

  • What is the expected behavior?
    Add a generic type parameter to open for typing the model (currently the model is simply of type any). For example:
dialogService.open<Customer>({
  viewModel: Dialog,
  model: {
    // TypeScript compiler would throw an error if this object wasn't of type Customer
    ...
  • What is the motivation / use case for changing the behavior?
    The consuming dialog view model would still need to manually type the model, as one currently would, but at least there would be a little more security on the other end knowing that what's being passed in is actually of type Customer.
export class Dialog implements DialogComponentActivate<Customer> {
  activate(model:Customer) {
    ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions