@@ -42,7 +42,7 @@ type TemplateProcessResult = {
42
42
moduleScriptTag : Node ;
43
43
/** To be added later as a comment on the default class export */
44
44
componentDocumentation : string | null ;
45
- events : Map < string , string > ;
45
+ events : Map < string , string | string [ ] > ;
46
46
} ;
47
47
48
48
class Scope {
@@ -542,7 +542,7 @@ function processInstanceScriptContent(str: MagicString, script: Node): InstanceS
542
542
if (
543
543
( ts . isPrefixUnaryExpression ( parent ) || ts . isPostfixUnaryExpression ( parent ) ) &&
544
544
parent . operator !==
545
- ts . SyntaxKind . ExclamationToken /* `!$store` does not need processing */
545
+ ts . SyntaxKind . ExclamationToken /* `!$store` does not need processing */
546
546
) {
547
547
let simpleOperator : string ;
548
548
if ( parent . operator === ts . SyntaxKind . PlusPlusToken ) {
@@ -844,8 +844,8 @@ function addComponentExport(
844
844
845
845
const statement = `\n\n${ doc } export default class ${
846
846
className ? `${ className } ` : ''
847
- } {\n $$prop_def = ${ propDef } \n $$slot_def = render().slots` +
848
- `\n $on = __sveltets_eventDef(render().events).$on\n}` ;
847
+ } {\n $$prop_def = ${ propDef } \n $$slot_def = render().slots` +
848
+ `\n $on = __sveltets_eventDef(render().events).$on\n}` ;
849
849
850
850
str . append ( statement ) ;
851
851
}
@@ -905,7 +905,7 @@ function createRenderFunction(
905
905
scriptTag : Node ,
906
906
scriptDestination : number ,
907
907
slots : Map < string , Map < string , string > > ,
908
- events : Map < string , string > ,
908
+ events : Map < string , string | string [ ] > ,
909
909
exportedNames : ExportedNames ,
910
910
uses$$props : boolean ,
911
911
uses$$restProps : boolean ,
@@ -945,9 +945,18 @@ function createRenderFunction(
945
945
} )
946
946
. join ( ', ' ) +
947
947
'}' ;
948
- const eventsDef = '{' + Array . from ( events . entries ( ) )
949
- . map ( ( [ evnetName , expression ] ) => `'${ evnetName } ':${ expression } ` )
950
- . join ( ', ' ) + '}' ;
948
+
949
+ const eventMapEntryToString = ( [ evnetName , expression ] : [
950
+ string ,
951
+ string | string [ ]
952
+ ] ) =>
953
+ `'${ evnetName } ':${
954
+ Array . isArray ( expression ) ? `[${ expression } ]` : expression
955
+ } `;
956
+ const eventsDef =
957
+ "{" +
958
+ Array . from ( events . entries ( ) ) . map ( eventMapEntryToString ) . join ( ", " ) +
959
+ "}" ;
951
960
952
961
const returnString = `\nreturn { props: ${ createPropsStr (
953
962
exportedNames ,
0 commit comments