`getObject()` for Yup reports types of DefinitelyTyped
See original GitHub issueHi @Haroenv and other maintainers 👋 Hope you are well! Thanks again for your continued effort on the projects in the Algolia ecosystem!
I’m not sure if I’m reporting this in the right place, but I wanted to reach out about what appears to be a data problem with npm-search
index (we’ve only seen a single library so far):
Running index.getObject()
with the package name yup
returns the following:
{
types: {
ts: 'definitely-typed',
definitelyTyped: '@types/yup',
},
}
However, on the npm website, the yup
package is reported as having built-in types and the @types/yup
package has been deprecated:
Both the current version and the beta version of yup
have no "types"
or "typings"
keys in the package.json
:
- https://unpkg.com/browse/yup@0.32.11/package.json
- https://unpkg.com/browse/yup@1.0.0-beta.8/package.json
For the current yup@0.32.11
, there is however no index.d.ts
in the root:
But there is one in yup@1.0.0-beta.8
:
Is the npm website or Algolia’s index wrong? (seems like npm website is wrong 🤔)
Our usage:
const client = algoliasearch(
'XXX',
'xxxxxxxxxxx',
);
const index = client.initIndex('npm-search');
const results = await index.getObject<AlgoliaObj>(dependency, {
attributesToRetrieve: ['types'],
});
const definitelyTypedPackageName = results.types?.definitelyTyped;
Issue Analytics
- State:
- Created 10 months ago
- Comments:19 (3 by maintainers)
Top GitHub Comments
I already tested the solution from @jablko and it seems to work fine
https://github.com/algolia/npm-search/issues/1089#issuecomment-1339544822
if @Haroenv approves I can create the PR in no time
I think the TypeScript compiler will look for a bundled
.d.ts
file first, before an@types/package
, so maybe this logic should be reversed: https://github.com/algolia/npm-search/blob/d99c31fbe733953d39e498f9c7d982b2e09f3458/src/typescript/index.ts#L69-L87I.e. if a package both contains built-in TypeScript declarations and a
@types/package
exists, the built-in declarations should take precedence.