We filter out the dependency if it does not have a types field, but an index.d.ts is also valid.
Example: p-event
We would need to check if the package contains an index.d.ts while filtering. We could make a HEAD request to unpkg.com for that, but that would not work for private packages. Alternatively, the filtering by package.json would probably completely go away if we used yarn 2 - then we can add a plugin to yarn that filters files on the fly
instead of pre-filtering entire packages out without knowing their content.
We could also open a streamed HTTP request to the tarball and only look at the file headers to see if a TypeScript file is in it. This would still be faster than downloading it with all its dependencies, but would mean all top-level dependencies need to be downloaded before dependency installation even starts.