We created types for theme in our React application that uses Typescript. Some issues are not identified by Typescript because of bracket notation. Example:
theme.colors["red:20"] //This should not give a typescript error and doesn't and works as expectedtheme.colors["gsdfgn"] //This should give me a typescript error but doesn't
The problem is we can't use keys like "red:20" without bracket notation and if we use bracket notation, typescript doesn't throw errors for any invalid values.
With dot notation we get typescript errors if we try to access any random value:
theme.colors.gsdfgn //This gives the typescript error and works as expected
We created types for theme in our React application that uses Typescript. Some issues are not identified by Typescript because of bracket notation. Example:
theme.colors["red:20"] //This should not give a typescript error and doesn't and works as expected
theme.colors["gsdfgn"] //This should give me a typescript error but doesn't
The problem is we can't use keys like "red:20" without bracket notation and if we use bracket notation, typescript doesn't throw errors for any invalid values. With dot notation we get typescript errors if we try to access any random value:theme.colors.gsdfgn //This gives the typescript error and works as expected