I've got a typescript/react project in which I am using @material components. There are definitions for those under @types/material__component. In the definitions there are often interfaces like (this one is from @types/material__menu/constants.d.ts):
export interface CornerBit extends MDCNumbers {
BOTTOM: 1;
CENTER: 2;
RIGHT: 4;
FLIP_RTL: 8;
}
Now if I wanna use CornerBit in my code I'd do:
import { CornerBit } from "@material/menu/"
@material/menu/index.js exports CornerBit from constants.js in which it is declared as:
const CornerBit = {
BOTTOM: 1,
CENTER: 2,
RIGHT: 4,
FLIP_RTL: 8,
};
Now when I import CornerBit like written above into my file and try to do:
const MyCornerBit = CornerBit;
I get:
TS2693: 'Corner' only refers to a type, but is being used as a value here.
So I guess I'm importing just the interface somehow, not the const itself. How do I use an interface like that (all properties have explicit values) though?
That just feels completely useless:
const MyCornerBit: CornerBit = {
BOTTOM: 1,
CENTER: 2,
RIGHT: 4,
FLIP_RTL: 8,
}
Thank you.
CornerBittoMyCornerBitand as the error says that’s not ok since it’s a type. If you want to sayMyCornerBitis of typeCornerBitthen use : instead of =. It’s a bit unclear what you’re trying to achieve