Skip to content

Commit

Permalink
feat(sfc): revert withDefaults() deprecation
Browse files Browse the repository at this point in the history
In some cases, the user still needs access to the full props object,
in such cases withDefaults() is still needed.
  • Loading branch information
yyx990803 committed Mar 31, 2023
1 parent f597146 commit 4af5d1b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

* **compiler-core:** support parsing `const` modifier in type parameters ([#7912](https://github.com/vuejs/core/issues/7912)) ([b7bd50f](https://github.com/vuejs/core/commit/b7bd50f5059e8755c0204f01a8c55b1724688e7e))
* **compiler-sfc:** add defineOptions macro ([#5738](https://github.com/vuejs/core/issues/5738)) ([bcf5841](https://github.com/vuejs/core/commit/bcf5841ddecc64d0bdbd56ce1463eb8ebf01bb9d))
* **compiler-sfc:** enable reactive props destructure by default and deprecate withDefaults() ([#7986](https://github.com/vuejs/core/issues/7986)) ([ba9c2ae](https://github.com/vuejs/core/commit/ba9c2ae247fcc3960b238a04cb635158daa82004))
* **compiler-sfc:** enable reactive props destructure by default ([#7986](https://github.com/vuejs/core/issues/7986)) ([ba9c2ae](https://github.com/vuejs/core/commit/ba9c2ae247fcc3960b238a04cb635158daa82004))
* **compiler-sfc:** improve runtime props inference for enum ([eded947](https://github.com/vuejs/core/commit/eded94712e37856f258dc8c85f98a26fa41ae05f))
* **compiler-sfc:** support generating variable instead of default export in compileScript ([71635be](https://github.com/vuejs/core/commit/71635be68d25887f91d624bb7f78281a851bc0cb))
* **compiler-sfc:** support module string names syntax ([#7428](https://github.com/vuejs/core/issues/7428)) ([0002567](https://github.com/vuejs/core/commit/000256772816d54976e462330a7be342c49c7304))
Expand Down
7 changes: 1 addition & 6 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export function compileScript(
): SFCScriptBlock {
let { script, scriptSetup, source, filename } = sfc
// feature flags
// TODO remove support for deprecated options when out of experimental
// TODO remove in 3.4
const enableReactivityTransform = !!options.reactivityTransform
const isProd = !!options.isProd
const genSourceMap = options.sourceMap !== false
Expand Down Expand Up @@ -524,11 +524,6 @@ export function compileScript(
if (!isCallOf(node, WITH_DEFAULTS)) {
return false
}
warnOnce(
`withDefaults() has been deprecated. ` +
`Props destructure is now reactive by default - ` +
`use destructure with default values instead.`
)
if (processDefineProps(node.arguments[0], declId)) {
if (propsRuntimeDecl) {
error(
Expand Down
2 changes: 0 additions & 2 deletions packages/runtime-core/src/apiSetupHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ type PropsWithDefaults<Base, Defaults> = Base & {
*
* This is only usable inside `<script setup>`, is compiled away in the output
* and should **not** be actually called at runtime.
*
* @deprecated use reactive props destructure instead.
*/
export function withDefaults<Props, Defaults extends InferDefaults<Props>>(
props: Props,
Expand Down

0 comments on commit 4af5d1b

Please sign in to comment.