In my class I have a property:
thousandSeparator: '' | ',' | ' ' | '.';
and want to set it by:
const options = {
thousandSeparator: ','
};
when setting this I get the error
Types of property 'thousandSeparator' are incompatible.
Type 'string' is not assignable to type '"" | "," | " " | "."'.
options.thousandSeparatorshould be const if you want to assign it to type'' | ',' | ' ' | '.'const options = { thousandSeparator: ',' as const };so','is actually of type','and not widened to type'string'.optionswith a propertythousandSeparator: '' | ',' | ' ' | '.';, as represented in the tsc link bytype optionsType = { thousandSeparator : '' | ',' | ' ' | '.'; };and thenconst options:optionsType = { thousandSeparator: ',' };Above, you've defined a variable, not an object property.