I have a JSON
file with color values that are structured like so:
{
"primaryBright": "#2DC6FB",
"primaryMain": "#05B4F0",
"primaryDarker": "#04A1D7",
"primaryDarkest": "#048FBE",
"secondaryBright": "#4CD2C0",
"secondaryMain": "#00BFA5",
"secondaryDarker": "#009884",
"secondaryDarkest": "#007F6E",
"tertiaryMain": "#FA555A",
"tertiaryDarker": "#F93C42",
"tertiaryDarkest": "#F9232A",
"darkGrey": "#333333",
"lightGrey": "#777777"
}
I'm attempting to bring this data into a .tsx
file. To do this, I updated the type definition as follows:
declare module "*.json" {
const value: any;
export default value;
}
The import statement in my file looks like this:
import colors = require('../colors.json')
To use the color primaryMain
, I reference it as colors.primaryMain
. However, I encounter an error message:
Property 'primaryMain' does not exist on type 'typeof "*.json"