Utilizing a third-party tool that has specified
editorStylingMode?: 'outlined' | 'underlined' | 'filled';
I have set the value in my environment.ts
file (in Angular) as shown below
export const environment = {
production: true,
editorStylingMode: 'filled'
};
This leads to an error in my code while assigning the value from the environment
config({
editorStylingMode: environment.editorStylingMode,
});
Type 'string' is not assignable to type '"filled" | "outlined" | "underlined"'
I tested the following solutions and they both resolve the issue
Solution 1
config({
editorStylingMode: environment.editorStylingMode as 'filled' | 'outlined' | 'underlined',
});
Solution 2
export const environment: {
production: boolean,
editorStylingMode: 'filled' | 'outlined' | 'underlined',
} = {
production: false,
editorStylingMode: 'filled'
};
Is there a more efficient way to handle this situation?