Skip to content

Commit 0eb9202

Browse files
richard-vineylpil
authored andcommitted
Fix invalid TS definition for long variant constructors with no args
1 parent 4b8758c commit 0eb9202

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,6 @@
163163
shadow outer scope variables in other branches when compiling to JavaScript.
164164
([Elias Haider](https://github.com/EliasDerHai))
165165

166+
- Fix invalid TypeScript definition being generated for variant constructors
167+
with long names that take no arguments.
168+
([Richard Viney](https://github.com/richard-viney))

compiler-core/src/javascript/typescript.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,12 +670,14 @@ impl<'a> TypeScriptGenerator<'a> {
670670
)
671671
.to_doc();
672672

673+
let has_arguments = !arguments.is_empty();
674+
673675
docvec![
674676
"export function ",
675677
name_with_generics(function_name, type_parameters),
676678
"(",
677679
docvec![break_("", ""), join(arguments, break_(",", ", ")),].nest(INDENT),
678-
break_(",", ""),
680+
break_(if has_arguments { "," } else { "" }, ""),
679681
"): ",
680682
type_name_with_generics.clone(),
681683
";"

0 commit comments

Comments
 (0)