Like Emotion and styled-components, System Props requires a TS declaration file that defines what the theme shape should be. So alongside your styled.d.ts or emotion.d.ts file, you'll also need a system-props.d.ts file.
import'system-props';
declaremodule'system-props'{
exportinterfaceTheme{
colors:{
blue100:string;
blue200:string;
green100:string;
green200:string;
};
space:{
'0':'0';
'1':'4px';
'2':'8px';
'3':'12px';
};
}
}
// Alternatively, use the Theme/DefaultTheme interface from styled-components or Emotion,
// if you already have type declaration files for them
import{DefaultTheme}from'styled-components';
import'system-props';
declaremodule'system-props'{
exportinterfaceThemeextendsDefaultTheme{}
}
Important note about your theme shape! In order for the props' types to work as expected, your theme shape must be a shallow and consistent nesting structure (demonstrated below). While more complex theme structures will still run just fine, the types exported from this library require this limited theme shape to consistently provide accurate and useful suggestions. To help you define this shape, you can extend the SystemPropsTheme interface.