79599256

Date: 2025-04-29 22:06:20
Score: 0.5
Natty:
Report link

Posting my own answer because people are already voting to close, and that's just not useful.

The answer is: it doesn't appear possible. I can either make result optional:

export interface ServiceResult<T> { result? T; }

... but that's not what I want, because I want the generic version to be guaranteed to have a T and the non-generic to never have a T.

The other option is to give the generic and non-generic classes different names, and inherit one from the other.

export interface ServiceResult1 {};
export interface ServiceResult2<T> extends ServiceResult1 { result: T };

Neither is optimal, so that answers both my questions.

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
Posted by: emery.noel