so basically, I’m working on a react-native library which exports some components and utilities to improve overall development.
In this library, I have a light and dark Theme, which I want to be able to override in my app code. To make this easier and intuitive, I want to import the type definition of a Theme from my library.
These 2 files comes from my library :
**src/types/CustomTheme.ts
declare type CustomTheme = {
dark: boolean;
colors: {
primary: string;
background: string;
card: string;
text: string;
textOnPrimary: string;
border: string;
variant: string;
notification: string;
inversed: string;
};
text: {
lg: number;
med: number;
sm: number;
};
};
export default CustomTheme;
**src/index.tsx
// Types for theme
import type CustomTheme from './types/CustomTheme';
export type { CustomTheme };
Then in my react-native app i’m doing :
import { type CustomTheme } from 'my-library';
let CustomLightTheme: CustomTheme = {
// Here VScode doesn't tells me that 'CustomLightTheme' is missing a lot of properties
};
Even if there is no errors, type checking is not really done here. For example, VSCode is not telling that my object miss some properties.
How can i have these kind of type checks when importing a type from my library ?