vuejs / vue-router

🚦 The official router for Vue 2
http://v3.router.vuejs.org/
MIT License
18.99k stars 5.06k forks source link

The type of query is wrong and may be undefined. #3878

Closed lzy1960 closed 7 months ago

lzy1960 commented 7 months ago

Version

3.6.5

Reproduction link

lzy1960/vue-router-query-ts-error

Steps to reproduce

run npx eslint src/views/HomeView.vue, then throw two eslint warning

What is expected?

  1. getElementsByClassName maybe return undefined, so secondPart is not always falsy
  2. this.$route.query.xxx maybe undefined, but the type is not contain undefined

In short, neither warning should appear.

What is actually happening?

Two no-autofix/@typescript-eslint/no-unnecessary-condition appeared that should not appear

posva commented 7 months ago

Duplicate of https://github.com/vuejs/router/issues/1891#issuecomment-1595987482

In short, it's a breaking change and it will happen in a next major