Fix call context (#1294) · TypeScriptToLua/TypeScriptToLua@70b61d9 · GitHub
Skip to content

Commit 70b61d9

Browse files
authored
Fix call context (#1294)
* Add tests for #1292 * Fix #1292 * Always use noImplicitSelf for node without signature declaration
1 parent 66bb36e commit 70b61d9

3 files changed

Lines changed: 35 additions & 6 deletions

File tree

‎src/transformation/visitors/call.ts‎

Lines changed: 10 additions & 6 deletions

‎test/unit/functions/noImplicitSelfOption.spec.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,17 @@ test("generates declaration files with @noSelfInFile", () => {
7979
.ignoreDiagnostics([couldNotResolveRequire.code]) // no foo implementation in the project to create foo.lua
8080
.expectToHaveNoDiagnostics();
8181
});
82+
83+
// https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1292
84+
test("explicit this parameter respected over noImplicitSelf", () => {
85+
util.testModule`
86+
function foo(this: unknown, arg: any) {
87+
return {self: this, arg};
88+
}
89+
export const result = foo(1);
90+
`
91+
.setOptions({
92+
noImplicitSelf: true,
93+
})
94+
.expectToMatchJsResult();
95+
});

‎test/unit/functions/noSelfAnnotation.spec.ts‎

Lines changed: 11 additions & 0 deletions

0 commit comments

Comments
 (0)