Typescript not operator not working

瘦欲@ 提交于 2019-12-11 05:32:09

问题


I have this function that runs after a multiselect element is changed that sets an error message visibility:

  getVisibility(multiselect) {
    if ((multiselect.selectedCategories.length < 1 && !multiselect.allSelected) && this.submitted) {
      return 'visible'
    } else {
      return 'hidden'
    }
  }

However in this line:

if ((multiselect.selectedCategories.length < 1 && !multiselect.allSelected) && this.submitted)

multiselect.allSelected is false, but !multiselect.allSelected is also false.

picture1:

picture2:

Why is the ! (not) the same boolean value as without the not?


回答1:


Typescript not operator not working

Its just JavaScript in the end and it most definitely works. The issue with the chrome dev tools and / or TypeScript source maps.

What I do:

  • Execute the command in the console (hovers can lie).
  • Disable source maps (More reasons : Chrome Typescript debugging references wrong 'this')


来源:https://stackoverflow.com/questions/39186189/typescript-not-operator-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!