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

beforeDestroy should be typed as never within defineComponent #12111

Open
scottbedard opened this issue Oct 4, 2024 · 1 comment
Open

beforeDestroy should be typed as never within defineComponent #12111

scottbedard opened this issue Oct 4, 2024 · 1 comment

Comments

@scottbedard
Copy link
Contributor

scottbedard commented Oct 4, 2024

Vue version

3.2+

Link to minimal reproduction

https://play.vuejs.org/#eNp9kk1P4zAQhv/KyJeCVDXS7p5Qd6X94MAeAAFHCyk408TgjKPxpE1V9b8zcRToAZAixZ55xn7f8RzM765bbXs0F2adHPtOIJRU/7RGkjW/LPm2iyxwgAo3nvBv1D0hCRxhw7GFhRYvLFnCIYOKlX3I/1P87GAJ4Ak3kfEfJuG4PzuHHAQoCngEiuIdgjSotR2jK8VHgl3J5KkebxhRaTjuYCGNT6BfCYzBu0nKt9WwhCtFPL1oRvYdAjJHhtTEPlR6/VRPKhjgaOl4bmldTL7Vq24E2y6UgroDWFd+mxcAKbaodzm1EvbQ+poVqsDN/jJeTPy6ODnFLLWTLtLG16vnFEkbnV1bM9b6gHzTjUa12xdzP6wpQ4i7/zkm3ONyjrsG3csH8ec0jDFrbhkT8hatectJyTXKlL68v8ZB12/JNlZ9UPqL5B2mGPpR44T96alS2SdcVnuVB0Wf6iFdDoKUZlOj0NzvzFujAzOOxWfW3+V+X/2Y38kcXwHt7uZ0

Steps to reproduce

Attempt to use beforeDestroy within defineComponent

What is expected?

A type error should be thrown

What is actually happening?

Only a deprecation warning is shown in the editor

System Info

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 674.00 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
    pnpm: 9.7.0 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 129.0.6668.90
    Firefox Nightly: 129.0a1
    Safari: 17.4.1
  npmPackages:
    vue: 3.5.10 => 3.5.10

Any additional comments?

When migrating large codebases, it's easy to miss things or have team members not realize an API has changed. We recently had beforeDestroy hooks used after our migration, and the error went unnoticed.

I've always understood the term "deprecated" to mean that something still works, but is on it's way out. Here, these functions have already been removed and no longer work.

I think typing these properties as never would be more helpful.

@yangliguo7
Copy link
Contributor

beforeDestroy can be invoked on COMPAT mode. I'm not sure if setting 'beforeDestroy' to 'never' would be a problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants