Open
Description
Description
When enabling exactOptionalPropertyTypes
in tsconfig compilerOptions
, I get warnings like:
TS2375: Type '{ username: string; displayName: string | undefined; }' is not assignable to type 'UserDto' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Types of property 'displayName' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'. [plugin angular-compiler]
On the following code:
const userDto: UserDto = {
username: user.username,
displayName: user.displayName,
};
The generated type looks like:
export interface UserDto {
displayName?: string;
username: string;
}
A working type would look like:
export interface UserDto {
displayName?: string | undefined;
username: string;
}
Maybe relevant, but old issue: #590