I have a predefined object:
const obj = {
ONE: 'ONE',
TWO: 'TWO'
};
I want to define assign the constant obj.ONE to a new type like this:
type TOne = obj.ONE
I get the following warning:
Cannot find namespace 'obj'. or 'ONE' refers to a value, but is being used as a type here. if I don't put the strings inside an object. Is there a fix around this to allow me to assign a predefined string to a type?
typeof obj.ONEstringto TOne, but I want type"ONE"'ONE'due to automatic type wideningas const, oras 'ONE'in the property definition. Otherwise, you're out of luck