-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Description
Hello!
I noticed some peculiarity when working with optional properties.
For example:
interface SomeInterface {
someOptionalProperty?: string;
}
const value: SomeInterface = { someOptionalProperty: undefined };
This code is quite valid and can be compiled without any problems.
Example with assertType:
For example:
interface SomeInterface {
someOptionalProperty?: string;
}
const value: SomeInterface = assertType<SomeInterface>({ someOptionalProperty: undefined });
In this case, I will get the error:
TypeGuardError: validation failed at $.someOptionalProperty: expected a string
Metadata
Metadata
Assignees
Labels
No labels