{
                  
                  
                    method: <R extends { abcent?:never }>(...args: any[]) => R;
                  
                  
                  };
                  
                  
                  
                  
                  
                  const test0: Type = {
                  
                  
                    method: (foo: string, bar: number) => ({
                  
                  
                      prop: foo + bar,
                  
                  
                    })
                  
                  
                  };
                  
                  
                  
                  
                  
                  const test1: Type = {
                  
                  
                    method: () => ({
                  
                  
                      abcent: 11, // expect error
                  
                  
                    })
                  
                  
                  };
                  
                  
                  
                  
                  
                  // need foo: {prop: string, abcent?:never}
                  
                  
                  const foo = test0.method('', 2);
                  
                  
                  
                  
                  
                  const bar = test0.method('', ''); // expect error because of the second param is string
                  
                  
                  
                  
                  
                  playground
                  
                  
                
важно обойтись без указания типа при вызове вроде test0.method<{prop: string}>(...)
Обсуждают сегодня