When we call the baz
function with the code provided, the typeahead will display 'a' and 'b' as potential values.
https://i.stack.imgur.com/SrKo7.png
If additional documentation is needed for each of these values, how can it be accomplished? For example, if the desired outcome is:
https://i.stack.imgur.com/Bbipq.png
To provide more context on the intention and purpose, let's consider the following example:
const paintColor = {
/** This color is good fo X */
Waltz: "#d9e5d7",
/** This color is good fo Y */
"Indiana Clay": "#ed7c4b",
/** This color is good fo Z */
Odyssey: "#575b6a"
};
const locations = {
/** There are no good school at this location*/
City: "123 city center road",
/** There are lots of parking at this location but it is very far*/
West: "245 some other road"
};
interface HouseProp {
color: keyof typeof paintColor; //"Waltz" | "Indiana Clay" | "Odyssey"
location: keyof typeof locations; //"City" | "West"
}
const House = ({ color, location }: HouseProp) => {
...
};
A react component called House renders a house based on the color and location props.
This House component is utilized extensively across the project.
Despite the current configuration, using House like this does not reflect the documented details in IntelliSense:
https://i.stack.imgur.com/ugG2L.png
The desired outcome would resemble this:
https://i.stack.imgur.com/4o4tt.pngRegarding the issue, while enums could be created for `paintColor` and `locations`, implementing them may not align with the original proposal.
import House, {HouseColor, HouseLocation} from './House';
<House color={HouseColor["Indiana Clay"]} location={HouseLocation.City} />
However, this approach lacks the elegance of the initial suggestion for the component interface.