@@ -66,43 +66,47 @@ test("@noSelf on static class methods with string key access", () => {
6666} ) ;
6767
6868// https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1661
69- test ( "@noSelf on interface with call signature removes context argument" , ( ) => {
69+ // A Lua-side function observes the actual argc, so a missing @noSelf would
70+ // surface as a phantom leading nil (argc 2 instead of 1).
71+ const argcProbeHeader = `
72+ function probe(...)
73+ return select("#", ...)
74+ end
75+ ` ;
76+
77+ test ( "@noSelf on interface call signature: Lua probe sees correct argc" , ( ) => {
7078 util . testModule `
7179 /** @noSelf */
72- interface CallSignature {
73- (): void ;
74- }
75- const func: CallSignature = () => {};
76- func();
77- ` . expectLuaToMatchSnapshot ( ) ;
80+ interface Probe { (a: string): number; }
81+ declare const probe: Probe ;
82+ export const result = probe("hi");
83+ `
84+ . setLuaHeader ( argcProbeHeader )
85+ . expectToEqual ( { result : 1 } ) ;
7886} ) ;
7987
80- // https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1661
81- test ( "@noSelf on parent interface applies to property with interface call-signature type" , ( ) => {
88+ test ( "@noSelf parent interface, property typed by call-signature interface: Lua probe sees correct argc" , ( ) => {
8289 util . testModule `
8390 /** @noSelf */
84- interface CallSignature {
85- (): void;
86- }
91+ interface CallSignature { (a: string): number; }
8792 /** @noSelf */
88- interface DemoType {
89- func: CallSignature ;
90- }
91- const demo: DemoType = { func: () => {} };
92- demo.func();
93- ` . expectLuaToMatchSnapshot ( ) ;
93+ interface Holder { fn: CallSignature; }
94+ declare const holder: Holder ;
95+ export const result = holder.fn("hi");
96+ `
97+ . setLuaHeader ( ` ${ argcProbeHeader } \nholder = { fn = probe }` )
98+ . expectToEqual ( { result : 1 } ) ;
9499} ) ;
95100
96- // https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1661
97- test ( "@noSelf on parent interface applies to property with type-literal call signature" , ( ) => {
101+ test ( "@noSelf parent interface, property typed by type-literal call signature: Lua probe sees correct argc" , ( ) => {
98102 util . testModule `
99103 /** @noSelf */
100- interface DemoType {
101- func: { (): void } ;
102- }
103- const demo: DemoType = { func: () => {} };
104- demo.func();
105- ` . expectLuaToMatchSnapshot ( ) ;
104+ interface Holder { fn: { (a: string): number }; }
105+ declare const holder: Holder ;
106+ export const result = holder.fn("hi");
107+ `
108+ . setLuaHeader ( ` ${ argcProbeHeader } \nholder = { fn = probe }` )
109+ . expectToEqual ( { result : 1 } ) ;
106110} ) ;
107111
108112// additional coverage for https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1292
0 commit comments