79336625

Date: 2025-01-07 16:15:30
Score: 0.5
Natty:
Report link

Got it. The trick is to have the library code use an ambient types from a d.ts file (probably nested under a namespace, but you do you), and then have the application code override that type in their own d.ts file.

Library:

// library-namespace.d.ts
namespace MyLibrary {
  type EventName: string; // we don't care in the lib.  String is fine.
}

Application:

// library-overrides.d.ts
namespace MyLibrary {
  type EventName: 'This' | 'That'; // app-specific event types
}
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Mike Snare