popupConfig types

Hello, I have some problems with typescript typing.
I'm using webix with JetView and typescript

I have such class:

export default class ErrorMessagePopup extends JetView {
  config(): webix.ui.popupConfig {
      const body:webix.ui.layoutConfig = {
        view:'layout',
        type: "clean",
        rows: [
          {
            view: "template",
            css: "error",
            template: `
            <h4>Error!</h4>
            <p>Your form wasn't submitted</p>`,
          },
        ],
      } 
    return {
      view: "popup",
      width: 500,
      height: 120,
      position: "top",
      css: "popup__wrapper",
      body:body
    } 
  }
}

VisualStudio complains about "body"

"Type 'layoutConfig' is not assignable to type 'string | baseview'."

According to "webix.global.d.ts" body should be string or baseview, but I can't convert "const body" to baseview as well...

Of course I could use "any" here, but I want my code to pass ESLint rules...

Comments

  • Should I just modify/override webix.global.d.ts ?

  • @michald1986
    try to modify body assignment as below

        return {
          view: "popup",
          width: 500,
          height: 120,
          position: "top",
          css: "popup__wrapper",
          body:body as unknown as string /*linter should be OK*/
        } 
    

    you already made body's type checking in upper lines code and assignment body as string should not make any problem with linter.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!