fix(codegen): print object property this param (#19783)

This commit is contained in:
camc314 committed 2026-02-27 08:28:11 +00:00
1 parent ca1169fbb1
commit 876dc1b0d6
2 files changed
+9

No files matched your search

+7
View File
@@ -1640,6 +1640,13 @@ impl Gen for ObjectProperty<'_> {
type_parameters.print(p, ctx);
}
p.print_ascii_byte(b'(');
if let Some(this_param) = &func.this_param {
this_param.print(p, ctx);
if !func.params.is_empty() || func.params.rest.is_some() {
p.print_ascii_byte(b',');
p.print_soft_space();
}
}
func.params.print(p, ctx);
p.print_ascii_byte(b')');
if let Some(return_type) = &func.return_type {
@@ -8,6 +8,8 @@ use crate::{
#[test]
fn cases() {
test_same("({ foo(): string {} });\n");
test_same("({ method(this: Foo): void {} });\n");
test_same("({ methodWithParam(this: Foo, bar: string): void {} });\n");
test_same("interface I<in out T,> {}\n");
test_same("function F<const in out T,>() {}\n");
test_same("class C {\n\tp = await(0);\n}\n");