Answer the question
In order to leave comments, you need to log in
How to type the following function?
I am mastering TS, writing a small application, here is a function from it in js:
const getLinksOnPage = () => {
return [...document.querySelectorAll('img')].map(item => item.src);
}
const getLinksOnPage = (): [string] => {
return [...document.querySelectorAll('img')].map(item => item.src);
};
Property '0' is missing in type 'any[]' but required in type '[string]'
Type 'NodeListOf<HTMLImageElement>' is not an array type
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question