AK
‘type’ in object
не является гардом
Size: a a a
AK
‘type’ in object
🦉
VK
OK
🦉
type WithType<T extends string> = {
type: T;
};
function isType(
object: { type?: unknown },
type: string,
): object is WithType<typeof type> {
if (typeof object.type === 'string') {
return object.type === type;
}
return false;
}
OK
AK
🦉
Element implicitly has an 'any' type because expression of type '"type"' can't be used to index type '{}'.
Property 'type' does not exist on type '{}'.
VK
OK
Element implicitly has an 'any' type because expression of type '"type"' can't be used to index type '{}'.
Property 'type' does not exist on type '{}'.
🦉
OK
OK
🦉
🦉
VK
OK
🦉
🦉
OK