'Exporting Typescript Module Declarations

I am working in a npm package that uses Mui v5. The package uses a modified theme with custom properties. The modified theme is correctly applied in the package, VSCode picks up the modified properties, and there are no compilation errors. This is achieved, in part, with this code:

// themeTypes.ts

import { Theme } from '@mui/material';

import colors from './colors';
import { status } from './status;

declare module '@mui/material/styles' {
  interface PaletteOptions {
     colors?: typeof colors;
  }
  interface ThemeOptions {
    status?: {
      [Key in keyof typeof status]: typeof status[Key];
    };
  }
  function createTheme(options?: ThemeOptions): Theme;
}

However, when this package is published and then used by another typescript app, this module augmentation doesn't get applied, or at least it's not correctly picked up by compiler.

I've tried lots of searching on how to 'pass along' this module declaration, but either don't know the correct terminology to search for, am barking up the wrong tree, or am being really dense (all 3??).



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source