Fullstack Developer and Freelancer

December 7, 2022

[TypeScript] Property 'offsetTop' does not exist on type 'Element'

The error “Property ‘offsetTop’ does not exist on type ‘Element’” occurs when we try to access the offsetTop property on an element that has a type of Element. To solve the error, use a type assertion to type the element as HTMLElement before accessing the property.