I am trying to follow various tutorials on the IntersectionObserver API, such as this one.
Adding the sample code into my component's TS file:
const myImg = document.querySelector('.animate-me');
observer = new IntersectionObserver((entry, observer) => {
console.log('entry:', entry);
console.log('observer:', observer);
});
observer.observe(myImg);
Gives me an error:
error TS2300: Duplicate identifier 'observer'.
Also, it complains about
const myImg = document.querySelector('.animate-me');
A class member cannot have the 'const' keyword.ts(1248)
what am I missing here?