Skip to content

Commit 7b25b3b

Browse files
committed
Add tests for #1292
1 parent b854f3f commit 7b25b3b

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

test/unit/functions/noImplicitSelfOption.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,17 @@ test("generates declaration files with @noSelfInFile", () => {
6767
.ignoreDiagnostics([couldNotResolveRequire.code]) // no foo implementation in the project to create foo.lua
6868
.expectToHaveNoDiagnostics();
6969
});
70+
71+
// https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1292
72+
test("explicit this parameter respected over noImplicitSelf", () => {
73+
util.testModule`
74+
function foo(this: unknown, arg: any) {
75+
return {self: this, arg};
76+
}
77+
export const result = foo(1);
78+
`
79+
.setOptions({
80+
noImplicitSelf: true,
81+
})
82+
.expectToMatchJsResult();
83+
});

test/unit/functions/noSelfAnnotation.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,14 @@ test("@noSelf on parent namespace declaration removes context argument", () => {
5151
MyNamespace.myMethod();
5252
`.expectLuaToMatchSnapshot();
5353
});
54+
55+
// additional coverage for https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1292
56+
test("explicit this parameter respected over @noSelf", () => {
57+
util.testModule`
58+
/** @noSelfInFile */
59+
function foo(this: unknown, arg: any) {
60+
return {self: this, arg};
61+
}
62+
export const result = foo(1);
63+
`.expectToMatchJsResult();
64+
});

0 commit comments

Comments
 (0)