@@ -777,6 +777,63 @@ function c({ _ = bar() + foo() }) {}
777777 ` )
778778} )
779779
780+ // #23232
781+ test ( 'function argument destructure with a default parameter' , async ( ) => {
782+ expect (
783+ await ssrTransformSimpleCode (
784+ `
785+ import { key } from 'foo'
786+ function noParameterDefault({ [key]: value = null }) {}
787+ function declaration({ [key]: value = null } = {}) {}
788+ function compound({ [key.name]: value } = {}) {}
789+ const arrow = ({ [key]: value = null } = {}) => {}
790+ function nested({ a: { [key]: value } = {} } = {}) {}
791+ function array([{ [key]: value } = {}] = []) {}
792+ class Foo { method({ [key]: value } = {}) {} }
793+ ` ,
794+ ) ,
795+ ) . toMatchInlineSnapshot ( `
796+ "const __vite_ssr_import_0__ = await __vite_ssr_import__("foo", {"importedNames":["key"]});
797+
798+
799+ function noParameterDefault({ [__vite_ssr_import_0__.key]: value = null }) {}
800+ function declaration({ [__vite_ssr_import_0__.key]: value = null } = {}) {}
801+ function compound({ [__vite_ssr_import_0__.key.name]: value } = {}) {}
802+ const arrow = ({ [__vite_ssr_import_0__.key]: value = null } = {}) => {};
803+ function nested({ a: { [__vite_ssr_import_0__.key]: value } = {} } = {}) {}
804+ function array([{ [__vite_ssr_import_0__.key]: value } = {}] = []) {}
805+ class Foo { method({ [__vite_ssr_import_0__.key]: value } = {}) {} }
806+ "
807+ ` )
808+ } )
809+
810+ test ( 'function argument destructure with a default parameter preserves shadowing' , async ( ) => {
811+ expect (
812+ await ssrTransformSimpleCode (
813+ `
814+ import { key } from 'foo'
815+ function shorthand({ key } = {}) { return key }
816+ function aliased({ prop: key } = {}) { return key }
817+ function defaulted({ key = 'default' } = {}) { return key }
818+ function array([key] = []) { return key }
819+ function plain(key) { return key }
820+ console.log(key)
821+ ` ,
822+ ) ,
823+ ) . toMatchInlineSnapshot ( `
824+ "const __vite_ssr_import_0__ = await __vite_ssr_import__("foo", {"importedNames":["key"]});
825+
826+
827+ function shorthand({ key } = {}) { return key }
828+ function aliased({ prop: key } = {}) { return key }
829+ function defaulted({ key = 'default' } = {}) { return key }
830+ function array([key] = []) { return key }
831+ function plain(key) { return key }
832+ console.log((0,__vite_ssr_import_0__.key))
833+ "
834+ ` )
835+ } )
836+
780837test ( 'object destructure alias' , async ( ) => {
781838 expect (
782839 await ssrTransformSimpleCode (
0 commit comments