Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined is complained when bind :style to an array #7955

Closed
yuwu9145 opened this issue Mar 25, 2023 · 0 comments · Fixed by #7954
Closed

Undefined is complained when bind :style to an array #7955

yuwu9145 opened this issue Mar 25, 2023 · 0 comments · Fixed by #7954
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. scope: types

Comments

@yuwu9145
Copy link
Contributor

yuwu9145 commented Mar 25, 2023

Vue version

3.2.47

Link to minimal reproduction

https://github.com/yuwu9145/vue-StyleValue-type

Steps to reproduce

  1. clone the repo
  2. run npx vue-tsc --noEmit

What is expected?

No type error

What is actually happening?

src/App.vue:2:17 - error TS2322: Type 'undefined' is not assignable to type 'StyleValue'.

2   <h1 :style="[ style, {background: 'green'} ]">Test</h1>

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
    Memory: 4.67 GB / 7.62 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.19.0 - ~/.nvm/versions/node/v16.19.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.19.0/bin/yarn
    npm: 8.19.3 - ~/.nvm/versions/node/v16.19.0/bin/npm
  npmPackages:
    vue: ^3.2.47 => 3.2.47

Any additional comments?

[undefined, {...other style object}] works perfectly fine in runtime. check link

In addition, undefined can be directly assigned to :style without type error

<h1 :style="undefined">Test</h1> // no type error

Therefore, [undefined] should not be type complained

@sxzz sxzz added the 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. label Mar 28, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. scope: types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants